Class: Ardb::CLI::GenerateMigrationCommand
- Inherits:
-
Object
- Object
- Ardb::CLI::GenerateMigrationCommand
- 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) ⇒ GenerateMigrationCommand
constructor
A new instance of GenerateMigrationCommand.
- #run ⇒ Object
Constructor Details
#initialize(argv, stdout = nil, stderr = nil) ⇒ GenerateMigrationCommand
Returns a new instance of GenerateMigrationCommand.
237 238 239 240 241 242 243 |
# File 'lib/ardb/cli.rb', line 237 def initialize(argv, stdout = nil, stderr = nil) @argv = argv @stdout = stdout || $stdout @stderr = stderr || $stderr @clirb = Ardb::CLIRB.new end |
Instance Attribute Details
#clirb ⇒ Object (readonly)
Returns the value of attribute clirb.
235 236 237 |
# File 'lib/ardb/cli.rb', line 235 def clirb @clirb end |
Instance Method Details
#help ⇒ Object
263 264 265 266 |
# File 'lib/ardb/cli.rb', line 263 def help "Usage: ardb generate-migration [options] MIGRATION-NAME\n\n" \ "Options: #{@clirb}" end |
#run ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/ardb/cli.rb', line 245 def run @clirb.parse!(@argv) begin require "ardb/migration" path = Ardb::Migration.new(@clirb.args.first).save!.file_path @stdout.puts "generated #{path}" rescue Ardb::Migration::NoIdentifierError => exception error = ArgumentError.new("MIGRATION-NAME must be provided") error.set_backtrace(exception.backtrace) raise error rescue StandardError => e @stderr.puts e @stderr.puts e.backtrace.join("\n") @stderr.puts "error generating migration" raise CommandExitError end end |