Class: CobraCommander::CLI

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

Constant Summary collapse

DEFAULT_CONCURRENCY =
(Concurrent.processor_count / 2.0).ceil

Instance Method Summary collapse

Instance Method Details

#changesObject



82
83
84
# File 'lib/cobra_commander/cli.rb', line 82

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

#exec(command_or_component, command = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cobra_commander/cli.rb', line 46

def exec(command_or_component, command = nil)
  results = CobraCommander::Executor.exec(
    components: components_filtered(command && command_or_component),
    command: command || command_or_component,
    concurrency: options.concurrency,
    status_output: $stderr
  )
  if options.interactive && results.size > 1
    CobraCommander::Output::InteractivePrinter.run(results, $stdout)
  else
    CobraCommander::Output::MarkdownPrinter.run(results, $stdout)
  end
end

#graph(component = nil) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/cobra_commander/cli.rb', line 69

def graph(component = nil)
  CobraCommander::Output::GraphViz.generate(
    find_component(component),
    options.output
  )
  puts "Graph generated at #{options.output}"
rescue ArgumentError => e
  error e.message
end

#ls(component = nil) ⇒ Object



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

def ls(component = nil)
  components = components_filtered(component)
  puts options.total ? components.size : CobraCommander::Output::FlatList.new(components).to_s
end

#tree(component = nil) ⇒ Object



61
62
63
64
# File 'lib/cobra_commander/cli.rb', line 61

def tree(component = nil)
  component = find_component(component)
  puts CobraCommander::Output::AsciiTree.new(component).to_s
end

#versionObject



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

def version
  puts CobraCommander::VERSION
end