Class: SolusVM::BaseCLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/solusvm/cli/base_cli.rb

Direct Known Subclasses

ClientCLI, GeneralCLI, NodeCLI, ResellerCLI, ServerCLI

Class Method Summary (collapse)

Class Method Details

Overrides the default banner implementation to output the whole command



12
13
14
# File 'lib/solusvm/cli/base_cli.rb', line 12

def banner(task, namespace = true, subcommand = false)
  "#{self.namespace.split(":").join(" ")} #{task.formatted_usage(self, false, false)}"
end

+ (Object) default_option(key)

Retrieves default options coming from a configuration file, if any.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/solusvm/cli/base_cli.rb', line 28

def default_option(key)
  @@yaml ||= begin
    file = File.join(File.expand_path(ENV['HOME']), '.solusvm.yml')
    if File.exists?(file)
      YAML::load(File.open(file))
    else
      {}
    end
  end

  @@yaml[key.to_s]
end

+ (Object) namespace(name = nil)

Convenience method to get the namespace from the class name. It's the same as Thor default except that the “_cli” at the end of the class is removed.



19
20
21
22
23
24
25
# File 'lib/solusvm/cli/base_cli.rb', line 19

def namespace(name=nil)
  if name
    super
  else
    @namespace ||= super.sub(/_cli$/, '')
  end
end