Class: Rooq::CLI

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/rooq/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ void

Parameters:

  • args (Array<String>)


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

#runInteger

Returns:

  • (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
  parse_options!

  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.message}"
  $stderr.puts e.backtrace.first(5).join("\n") if ENV["DEBUG"]
  1
end