Class: Ardb::CLI::CreateCommand
- Inherits:
-
Object
- Object
- Ardb::CLI::CreateCommand
- Defined in:
- lib/ardb/cli.rb,
lib/ardb/cli.rb
Instance Attribute Summary collapse
-
#clirb ⇒ Object
readonly
Returns the value of attribute clirb.
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(argv, stdout = nil, stderr = nil) ⇒ CreateCommand
constructor
A new instance of CreateCommand.
- #run ⇒ Object
Constructor Details
#initialize(argv, stdout = nil, stderr = nil) ⇒ CreateCommand
Returns a new instance of CreateCommand.
139 140 141 142 143 144 145 146 |
# File 'lib/ardb/cli.rb', line 139 def initialize(argv, stdout = nil, stderr = nil) @argv = argv @stdout = stdout || $stdout @stderr = stderr || $stderr @clirb = Ardb::CLIRB.new @adapter = Ardb::Adapter.send(Ardb.config.db.adapter) end |
Instance Attribute Details
#clirb ⇒ Object (readonly)
Returns the value of attribute clirb.
137 138 139 |
# File 'lib/ardb/cli.rb', line 137 def clirb @clirb end |
Instance Method Details
#help ⇒ Object
160 161 162 163 |
# File 'lib/ardb/cli.rb', line 160 def help "Usage: ardb create [options]\n\n" \ "Options: #{@clirb}" end |
#run ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/ardb/cli.rb', line 148 def run @clirb.parse!(@argv) begin @adapter.create_db @stdout.puts "created #{Ardb.config.db.adapter} db `#{Ardb.config.db.database}`" rescue StandardError => e @stderr.puts e @stderr.puts "error creating #{Ardb.config.db.database.inspect} database" raise CommandExitError end end |