Module: Stealth::CliBase
- Included in:
- Cli
- Defined in:
- lib/stealth/cli_base.rb
Instance Method Summary collapse
- #banner(command, nspace = true, subcommand = false) ⇒ Object
- #define_commands(&blk) ⇒ Object
- #handle_argument_error(command, error, args, arity) ⇒ Object
Instance Method Details
#banner(command, nspace = true, subcommand = false) ⇒ Object
10 11 12 |
# File 'lib/stealth/cli_base.rb', line 10 def (command, nspace = true, subcommand = false) super(command, nspace, namespace != 'stealth:cli') end |
#define_commands(&blk) ⇒ Object
6 7 8 |
# File 'lib/stealth/cli_base.rb', line 6 def define_commands(&blk) class_eval(&blk) if block_given? end |
#handle_argument_error(command, error, args, arity) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/stealth/cli_base.rb', line 14 def handle_argument_error(command, error, args, arity) name = [(namespace == 'stealth:cli' ? nil : namespace), command.name].compact.join(" ") msg = "ERROR: \"#{basename} #{name}\" was called with " msg << "no arguments" if args.empty? msg << "arguments " << args.inspect unless args.empty? msg << "\nUsage: #{(command).inspect}" raise Thor::InvocationError, msg end |