Class: Crowbar::Client::App::Base

Inherits:
Thor
  • Object
show all
Defined in:
lib/crowbar/client/app/base.rb

Overview

A base class that provides helper for the wrappers

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], local_options = {}, config = {}) ⇒ Crowbar::Client::App::Base

Initialize the Thor command



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/crowbar/client/app/base.rb', line 35

def initialize(args = [], local_options = {}, config = {})
  super

  Config.configure(
    options.slice(
      :alias,
      :username,
      :password,
      :server,
      :timeout,
      :anonymous,
      :debug
    )
  )
end

Class Method Details

A banner that gets displayed on help and error



140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/crowbar/client/app/base.rb', line 140

def banner(command, namespace = nil, subcommand = true)
  addition = command.formatted_usage(
    self,
    false,
    subcommand
  )

  [
    basename,
    addition
  ].compact.join(" ")
end

.handle_argument_error(command, error, args, arity) ⇒ Object

Properly print an error on invalid command



127
128
129
130
# File 'lib/crowbar/client/app/base.rb', line 127

def handle_argument_error(command, error, args, arity)
  $stderr.puts("Usage: #{banner(command)}")
  exit(2)
end