Class: SolusVM::BaseCLI
- Inherits:
-
Thor
- Object
- Thor
- SolusVM::BaseCLI
- Includes:
- Thor::Actions
- Defined in:
- lib/solusvm/cli/base_cli.rb
Direct Known Subclasses
Class Method Summary (collapse)
-
+ (Object) banner(task, namespace = true, subcommand = false)
Overrides the default banner implementation to output the whole command.
-
+ (Object) default_option(key)
Retrieves default options coming from a configuration file, if any.
-
+ (Object) namespace(name = nil)
Convenience method to get the namespace from the class name.
Class Method Details
+ (Object) banner(task, namespace = true, subcommand = false)
Overrides the default banner implementation to output the whole command
12 13 14 |
# File 'lib/solusvm/cli/base_cli.rb', line 12 def (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.(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 |