Module: Spire::Commands::CLI
- Defined in:
- lib/spire/commands/cli.rb
Overview
This is the spire command
Constant Summary collapse
Class Method Summary collapse
- .rc ⇒ Object
- .run(subcommand, *args) ⇒ Object
- .save_rc ⇒ Object
- .url ⇒ Object
- .usage(message) ⇒ Object
Class Method Details
.rc ⇒ Object
28 29 30 |
# File 'lib/spire/commands/cli.rb', line 28 def self.rc @rc ||= (YAML.load_file(File.("~/.spirerc")) rescue {}) end |
.run(subcommand, *args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spire/commands/cli.rb', line 15 def self.run(subcommand,*args) if command = COMMANDS[subcommand] begin command.run(args) rescue => e $stderr.puts "spire: #{e.}" exit(-1) end else usage "#{subcommand} is not a supported command" end end |
.save_rc ⇒ Object
32 33 34 |
# File 'lib/spire/commands/cli.rb', line 32 def self.save_rc File.open(File.("~/.spirerc"),"w") { |f| YAML.dump(rc,f) } end |
.url ⇒ Object
36 37 38 |
# File 'lib/spire/commands/cli.rb', line 36 def self.url rc["url"]||"https://api.spire.io" end |
.usage(message) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/spire/commands/cli.rb', line 40 def self.usage() $stderr.puts "spire: #{}" $stderr.puts <<-eos Usage: spire <subcommand> <options> The spire command provides command line access to the spire.io API. Valid commands: register Register a new account console Open up an IRB session with an open spire session. You can get more options for any command with --help or -h. eos exit(-1) end |