Class: Rooq::CLI
Instance Method Summary collapse
- #initialize(args) ⇒ void constructor
- #run ⇒ Integer
Constructor Details
#initialize(args) ⇒ void
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rooq/cli.rb', line 13 def initialize(args) @args = args @options = T.let({ schema: "public", output: nil, stdout: false, typed: true, namespace: "Schema", database: nil, host: "localhost", port: 5432, username: nil, password: nil }, T::Hash[Symbol, T.untyped]) end |
Instance Method Details
#run ⇒ Integer
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rooq/cli.rb', line 30 def run case @args.first when "generate", "gen", "g" generate_command when "version", "-v", "--version" version_command when "help", "-h", "--help", nil help_command else $stderr.puts "Unknown command: #{@args.first}" $stderr.puts "Run 'rooq help' for usage information." 1 end rescue StandardError => e $stderr.puts "Error: #{e.}" $stderr.puts e.backtrace.first(5).join("\n") if ENV["DEBUG"] 1 end |