Created
June 9, 2011 04:52
-
-
Save playupchris/1016087 to your computer and use it in GitHub Desktop.
Problems using clamp with explicit subcommand class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'clamp' | |
class InitCommand < Clamp::Command | |
def execute | |
puts "initializing from another file" | |
end | |
end | |
class MainCommand < Clamp::Command | |
option '--debug', :flag, "Show stacktraces on error", :default => false | |
subcommand "init1", "Initialize the repository (from another file)", InitCommand | |
subcommand "init2", "Initialize the repository (inline)" do | |
def execute | |
puts "initializing inline" | |
end | |
end | |
end | |
MainCommand.run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./explicit_subcommand_class.rb --help | |
Usage: | |
explicit_subcommand_class.rb [OPTIONS] SUBCOMMAND [ARGS] ... | |
Parameters: | |
SUBCOMMAND subcommand name | |
[ARGS] ... subcommand arguments | |
Subcommands: | |
init1 Initialize the repository (from another file) | |
init2 Initialize the repository (inline) | |
Options: | |
--debug Show stacktraces on error (default: false) | |
--debug Show stacktraces on error (default: false) | |
--help print help | |
$ ./explicit_subcommand_class.rb init1 --help | |
Usage: | |
explicit_subcommand_class.rb init1 | |
$ ./explicit_subcommand_class.rb init2 --help | |
Usage: | |
explicit_subcommand_class.rb init2 [OPTIONS] | |
Options: | |
--debug Show stacktraces on error (default: false) | |
--help print help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment