Class: Tomo::Commands::Default

Inherits:
Tomo::CLI::Command show all
Includes:
Tomo::CLI::CommonOptions
Defined in:
lib/tomo/commands/default.rb

Instance Method Summary collapse

Methods included from Tomo::CLI::CommonOptions

included

Methods inherited from Tomo::CLI::Command

after_parse, arg, option, parse, parser

Methods included from Tomo::Colors

enabled?

Instance Method Details



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tomo/commands/default.rb', line 15

def banner
  <<~BANNER
    Usage: #{green('tomo')} #{yellow('COMMAND [options]')}

    Tomo is an extensible tool for deploying projects to remote hosts via SSH.
    Please specify a #{yellow('COMMAND')}, which can be:

    #{commands.map { |name, help| "  #{yellow(name.ljust(10))} #{help}" }.join("\n")}

    The tomo CLI also provides some convenient shortcuts:

    - Commands can be abbreviated, like #{blue('tomo d')} to run #{blue('tomo deploy')}.
    - When running tasks, the #{yellow('run')} command is implied and can be omitted.
      E.g., #{blue('tomo run rails:console')} can be shortened to #{blue('tomo rails:console')}.
    - Bash completions are also available. Run #{blue('tomo completion-script')} for
      installation instructions.

    For help with any command, add #{blue('-h')} to the command, like this:

      #{blue('tomo run -h')}

    Or read the full documentation for all commands at:

      #{blue('https://tomo.mattbrictson.com/')}
  BANNER
end

#call(*args, options) ⇒ Object



42
43
44
45
46
47
48
49
50
51
# File 'lib/tomo/commands/default.rb', line 42

def call(*args, options)
  # The bare `tomo` command (i.e. without `--help` or `--version`) doesn't
  # do anything, so if we got this far, something has gone wrong.

  if options.any?
    raise CLI::Error, "Options must be specified after the command: " + yellow("tomo #{args.first} [options]")
  end

  raise_unrecognized_command(args.first)
end