Class: Butcher::Stab::CLI
- Inherits:
-
Object
- Object
- Butcher::Stab::CLI
- Defined in:
- lib/butcher/stab/cli.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
Returns the value of attribute argv.
-
#kernel ⇒ Object
Returns the value of attribute kernel.
-
#options ⇒ Object
Returns the value of attribute options.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ CLI
constructor
A new instance of CLI.
- #node_name ⇒ Object
- #usage ⇒ Object
Constructor Details
#initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel) ⇒ CLI
Returns a new instance of CLI.
4 5 6 7 8 9 10 11 12 |
# File 'lib/butcher/stab/cli.rb', line 4 def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel) self.argv = argv self.stdin = stdin self.stdout = stdout self.stderr = stderr self.kernel = kernel self. = {} optparse end |
Instance Attribute Details
#argv ⇒ Object
Returns the value of attribute argv.
2 3 4 |
# File 'lib/butcher/stab/cli.rb', line 2 def argv @argv end |
#kernel ⇒ Object
Returns the value of attribute kernel.
2 3 4 |
# File 'lib/butcher/stab/cli.rb', line 2 def kernel @kernel end |
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/butcher/stab/cli.rb', line 2 def @options end |
#stderr ⇒ Object
Returns the value of attribute stderr.
2 3 4 |
# File 'lib/butcher/stab/cli.rb', line 2 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
2 3 4 |
# File 'lib/butcher/stab/cli.rb', line 2 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
2 3 4 |
# File 'lib/butcher/stab/cli.rb', line 2 def stdout @stdout end |
Instance Method Details
#execute! ⇒ Object
14 15 16 17 18 19 |
# File 'lib/butcher/stab/cli.rb', line 14 def execute! return stdout.puts(usage) if [:help] raise Butcher::Stab::UsageError.new(usage) if node_name.nil? ssh_to(matching_node) end |
#node_name ⇒ Object
21 22 23 |
# File 'lib/butcher/stab/cli.rb', line 21 def node_name @node_name ||= argv.shift end |
#usage ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/butcher/stab/cli.rb', line 25 def usage <<-END.gsub(/^ {6}/, '') Usage: stab [options] <node name> [ssh options] -f --force # download new node list even if a cache file exists -v --verbose # be expressive -h --help # print this info END end |