Class: ERDB::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/erdb/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean



52
53
54
# File 'lib/erdb/cli.rb', line 52

def self.exit_on_failure?
  true
end

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/erdb/cli.rb', line 10

def create
  ERDB.default_browser = options[:browser].to_sym
  ERDB.show_junction_table = options[:junction_table]

  ARGV.clear

  say Messages.welcome

  db = select_database

  erd_builder = select_diagram_builder

  db.connect

  erd_builder.create(db.to_erdb)
rescue Interrupt
  say "\n\nThank you for using ERDB!", :blue
  exit 0
rescue ActiveRecord::NoDatabaseError
  say "\nError: Database not found.", :red
  say "Please make sure the database exists."
  exit 1
rescue StandardError => e
  say "Error: #{e.message}", :red
  exit 1
end

#helpObject



47
48
49
50
# File 'lib/erdb/cli.rb', line 47

def help
  say Messages.help
  super
end

#versionObject



41
42
43
# File 'lib/erdb/cli.rb', line 41

def version
  say "ERDB #{ERDB::VERSION}"
end