Skip to content

Commit

Permalink
* small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gettalong committed Apr 5, 2006
1 parent 361373f commit 034acd4
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion doc/src/tutorial.page
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,50 @@ title: Tutorial
inMenu: true
orderInfo: 6
---
h2. Tutorial
h2. Quickstart

Here are some short code fragments which show how to use cmdparse. A complete example app can be
found later in the "tutorial section":#tutorial.

Defining commands using classes:
<pre>
class TestCmd < CmdParse::Command
def initialize
super('test', true)
self.add_command(TestSubCmd.new)
end
end

class TestSubCmd < CmdParse::Command
def initialize
super('sub',false)
end

def execute (args)
puts "Hallo #{args}"
end
end

cmd = CmdParse::CommandParser.new( true )
cmd.add_command(TestCmd.new)
</pre>

Defining command using the basic @CmdParse::Command@ class:
<pre>
cmd = CmdParse::CommandParser.new( true )
testcmd = CmdParse::Command.new( 'test', true )
testcmd.short_desc = "Short desc"
cmd.add_command( testcmd )

sub = CmdParse::Command.new( 'sub', false )
sub.short_desc = "Add an IP address"
sub.set_execution_block do |args|
puts "Hallo #{args}"
end
testcmd.add_command( sub )
</pre>

h2(#tutorial). Tutorial

<b>The complete code for this example can be found in the file @net.rb@ of the @cmdparse@
package!</b>
Expand Down

0 comments on commit 034acd4

Please sign in to comment.