Class: Sod::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/sod/shell.rb

Overview

The Command Line Interface (CLI).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = Cogger::Program.call, banner: nil, node: Graph::Node, runner: Graph::Runner, &block) ⇒ Shell

rubocop:todo Metrics/ParameterLists



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/sod/shell.rb', line 11

def initialize name = Cogger::Program.call,
               banner: nil,
               node: Graph::Node,
               runner: Graph::Runner,
               &block
  @name = name.to_s
  @banner = banner
  graph = node[handle: name, description: banner]
  graph.instance_eval(&block) if block
  @runner = runner.new graph
end

Instance Attribute Details

Returns the value of attribute banner.



8
9
10
# File 'lib/sod/shell.rb', line 8

def banner
  @banner
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/sod/shell.rb', line 8

def name
  @name
end

Instance Method Details

#call(arguments = ARGV, process: Process) ⇒ Object

rubocop:enable Metrics/ParameterLists



24
25
26
27
# File 'lib/sod/shell.rb', line 24

def call arguments = ARGV, process: Process
  process.setproctitle name
  runner.call arguments
end