class Crew::CLI

Public Instance Methods

contexts(args) click to toggle source

tasks

# File lib/crew/cli.rb, line 75
def contexts(args)
  Contexts.new.process(args)
end
docs(args) click to toggle source

general

# File lib/crew/cli.rb, line 65
def docs(args)
  opts = Trollop::options(args) do
    opt :open, "Open docs after generation", short: "o"
  end
  path = crew_home.docs
  `open #{path}` if opts[:open]
end
help(args) click to toggle source

overall

# File lib/crew/cli.rb, line 52
def help(args)
  puts help_message
end
init(args) click to toggle source
# File lib/crew/cli.rb, line 56
def init(args)
  opts = Trollop::options(args) do
    opt :force, "Force creation"
  end
  args << opts
  Home.init(*args)
end
process(args) click to toggle source
# File lib/crew/cli.rb, line 41
def process(args)
  cmds = commands
  global_opts = Trollop::options(args) do
    opt :no_color, "Don't use colored output"
    stop_on cmds
  end
  Rainbow.enabled = global_opts[:no_color] == false
  dispatch(args)
end
run(args) click to toggle source
# File lib/crew/cli.rb, line 93
def run(args)
  opts = Trollop::options(args) do
    opt :setup, "Enable setup mode", short: "-s"
    opt :context, "Context name", short: "-c", type: String
  end
  task_name = args.shift
  raise "You must specify a task name" if task_name.nil?
  home = crew_home
  home.setup_mode = opts[:setup]
  home.run(opts[:context], task_name, *args)
end
shell(args) click to toggle source
# File lib/crew/cli.rb, line 83
def shell(args)
  opts = Trollop::options(args) do
    opt :setup, "Enable setup mode", short: "-s"
    opt :context, "Context name", short: "-c", type: String
  end
  home = crew_home
  home.setup_mode = opts[:setup]
  home.shell(opts[:context])
end
tasks(args) click to toggle source
# File lib/crew/cli.rb, line 79
def tasks(args)
  Tasks.new.process(args)
end
test(args) click to toggle source
# File lib/crew/cli.rb, line 105
def test(args)
  opts = Trollop::options(args) do
    opt :force, "Force running", short: "-f"
    opt :fast, "Fail fast"
    opt :failed_only, "Fail fast", short: "-o"
    opt :test_name, "Test name", short: "-t", type: String
    opt :context_name, "Context name", short: "-c", type: String
    opt :force_prepare, "Force preparing", short: "-p"
  end
  crew_home.test(opts)
end

Private Instance Methods

commands() click to toggle source
# File lib/crew/cli.rb, line 143
def commands
  %w(help init docs shell run tasks contexts test)
end
error(message) click to toggle source
# File lib/crew/cli.rb, line 138
def error(message)
  warn message
  exit(1)
end
help_message() click to toggle source
# File lib/crew/cli.rb, line 118
    def help_message
      <<-HEREDOCS

#{"# Crew #{Crew::VERSION}".color(:magenta)}

#{"General                        ".bright}
#{"===============================".bright}

#{"help                           ".color(:blue).bright}provides help
#{"init                           ".color(:blue).bright}initializes crew
#{"status                         ".color(:blue).bright}gets the current status of crew
#{"docs                           ".color(:blue).bright}generates and opens html docs
#{"test                           ".color(:blue).bright}runs tests

#{Tasks.new.help_message}

#{Contexts.new.help_message}
      HEREDOCS
    end