Class: Keg::CLI
- Inherits:
-
Thor
- Object
- Thor
- Keg::CLI
- Defined in:
- lib/keg/cli.rb
Constant Summary collapse
- DEFAULT_FORMAT =
'json'
Class Method Summary collapse
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #show(filename) ⇒ Object
- #show_all ⇒ Object
- #switch(name) ⇒ Object
Constructor Details
Class Method Details
.exit_on_failure? ⇒ Boolean
7 |
# File 'lib/keg/cli.rb', line 7 def self.exit_on_failure?; true end |
Instance Method Details
#current ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/keg/cli.rb', line 38 def current begin puts @database.current rescue => e raise Thor::InvocationError.new(e.) end end |
#show(filename) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/keg/cli.rb', line 26 def show(filename) begin content = @database.select(filename) formatter = Formatter.create([:format]) rescue => e raise Thor::InvocationError.new(e) end puts formatter.format(content) end |
#show_all ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/keg/cli.rb', line 48 def show_all begin contents = @database.select_all formatter = Formatter.create([:format]) rescue => e raise Thor::InvocationError.new(e) end contents.each do |content| puts formatter.format(content) end end |
#switch(name) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/keg/cli.rb', line 15 def switch(name) begin @database.switch name rescue => e raise Thor::InvocationError.new(e) end puts "Switch dataBase `#{name}`." end |