Argy::Command
A Command represents a single verb in the CLI hierarchy.
Example:
root = Argy::Command.new( use: "mytool", short: "A fictional dev tool", long: "mytool is a fictional dev tool used to illustrate argy." )
serve = Argy::Command.new( use: "serve [flags]", short: "Start the HTTP server" ) serve.on_run do |cmd, _args| port = cmd.int_flag("port") puts "Serving on port #{port}" end serve.flags.int("port", 'p', 8080, "port to listen on")
root.add_command(serve) root.execute
Constructors
Instance methods
Call this on the root command to parse ARGV and dispatch.
If the first token equals this command's own name (e.g. the user passed
the program name explicitly), it is stripped before routing so that
myapp myapp subcommand and myapp subcommand behave identically.
Renders the standard "Error: … / Run '… --help' for usage." diagnostic for
a failed execute to io (this command's stderr by default). Public so
callers that handle their own errors can reuse argy's formatting.
The stream this command writes errors to (own override, else inherited,
else the process STDERR).
The stream this command prints to (own override, else inherited, else
the process STDOUT).
The usage line – first word is treated as the command name. e.g. "serve [flags]" or just "serve"