Class: Crew::CLI

Inherits:
Object
  • Object
show all
Includes:
Processor
Defined in:
lib/crew/cli.rb,
lib/crew/cli/tasks.rb,
lib/crew/cli/contexts.rb

Defined Under Namespace

Modules: Processor Classes: Contexts, Tasks

Instance Method Summary collapse

Methods included from Processor

#dispatch

Instance Method Details

#contexts(args) ⇒ Object

tasks



75
76
77
# File 'lib/crew/cli.rb', line 75

def contexts(args)
  Contexts.new.process(args)
end

#docs(args) ⇒ Object

general



65
66
67
68
69
70
71
# 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) ⇒ Object

overall



52
53
54
# File 'lib/crew/cli.rb', line 52

def help(args)
  puts help_message
end

#init(args) ⇒ Object



56
57
58
59
60
61
62
# 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) ⇒ Object



41
42
43
44
45
46
47
48
49
# 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) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
# 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) ⇒ Object



83
84
85
86
87
88
89
90
91
# 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) ⇒ Object



79
80
81
# File 'lib/crew/cli.rb', line 79

def tasks(args)
  Tasks.new.process(args)
end

#test(args) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# 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