Class: CobraCommander::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/cobra_commander/cli.rb,
lib/cobra_commander/cli/filters.rb,
lib/cobra_commander/cli/output/change.rb,
lib/cobra_commander/cli/output/dot_graph.rb

Defined Under Namespace

Modules: Output

Constant Summary collapse

DEFAULT_CONCURRENCY =
(Etc.nprocessors / 2.0).ceil

Instance Method Summary collapse

Instance Method Details

#changesObject



96
97
98
# File 'lib/cobra_commander/cli.rb', line 96

def changes
  Output::Change.new(umbrella, options.branch).run!
end

#cmd(command_or_components, command = nil) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/cobra_commander/cli.rb', line 64

def cmd(command_or_components, command = nil)
  CobraCommander::Executor.execute_and_handle_exit(
    runner: ::CobraCommander::Executor::Command.new(command || command_or_components),
    workers: options.concurrency,
    interactive: options.interactive,
    jobs: components_filtered(command && command_or_components).flat_map(&:packages)
  )
end

#exec(script_or_components, script = nil) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/cobra_commander/cli.rb', line 46

def exec(script_or_components, script = nil)
  CobraCommander::Executor.execute_and_handle_exit(
    runner: ::CobraCommander::Executor::Script.new(script || script_or_components),
    workers: options.concurrency,
    interactive: options.interactive,
    jobs: components_filtered(script && script_or_components)
  )
end

#graph(component = nil) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/cobra_commander/cli.rb', line 81

def graph(component = nil)
  output = File.open(options.output, "w")
  Output::DotGraph.generate(
    component ? [find_component(component)] : umbrella.components,
    output
  )
  puts "Graph generated at #{options.output}"
rescue ArgumentError => e
  error e.message
ensure
  output&.close
end

#ls(components = nil) ⇒ Object



32
33
34
35
# File 'lib/cobra_commander/cli.rb', line 32

def ls(components = nil)
  components = components_filtered(components)
  puts options.total ? components.size : components.map(&:name).sort
end

#tree(component = nil) ⇒ Object



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

def tree(component = nil)
  components = component ? [find_component(component)] : umbrella.components
  puts Output::AsciiTree.new(components).to_s
end

#versionObject



24
25
26
# File 'lib/cobra_commander/cli.rb', line 24

def version
  puts CobraCommander::VERSION
end