Class: Gogdb::Cli
- Inherits:
-
Thor
- Object
- Thor
- Gogdb::Cli
- Defined in:
- lib/gogdb/cli.rb
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(*args) ⇒ Cli
constructor
A new instance of Cli.
- #setup ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(*args) ⇒ Cli
Returns a new instance of Cli.
4 5 6 7 |
# File 'lib/gogdb/cli.rb', line 4 def initialize(*args) check_config super end |
Instance Method Details
#fetch ⇒ Object
23 24 25 26 |
# File 'lib/gogdb/cli.rb', line 23 def fetch @e = Gogdb::Engine.new() @e.fetch() end |
#setup ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gogdb/cli.rb', line 29 def setup db_path = ask("Enter path you want to save database (default #{ENV['HOME']}/.gogdb):") db_path = "#{ENV['HOME']}/.gogdb" if db_path.empty? @config = { "path" => db_path } # Stop execution if user does not want to overwrite. if File.exist?("config.yml") exit unless yes? "Config file already exists. Overwrite?(y/n)", :red end File.open("config.yml", "w") { |file| file.write(@config.to_yaml) } say "Config written successfully.", :green end |