Module: Stealth::CliBase

Included in:
Cli
Defined in:
lib/stealth/cli_base.rb

Instance Method Summary collapse

Instance Method Details



10
11
12
# File 'lib/stealth/cli_base.rb', line 10

def banner(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

Raises:

  • (Thor::InvocationError)


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: #{banner(command).inspect}"

  raise Thor::InvocationError, msg
end