Class: Ludwig::CLI

Inherits:
Object
  • Object
show all
Includes:
Commander::Methods
Defined in:
lib/ludwig/cli.rb

Instance Method Summary collapse

Instance Method Details

#runObject



7
8
9
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
# File 'lib/ludwig/cli.rb', line 7

def run
  program :version, Ludwig::VERSION
  program :description, 'Ludwig, the famous composer'

  @config_file = 'ludwig.yml'

  global_option('-d', '--debug', 'Enable debug mode') { $debug = true }
  global_option('-c', '--config filename', String, 'Set config filename') { |config_file| @config_file = config_file }

  command :compose do |c|
    c.syntax = 'ludwig compose [options]'
    c.summary = 'Generate docker-compose.yml'
    c.action do |args, options|
      generate_compose_file
    end
  end

  command :up do |c|
    c.syntax = 'ludwig up [options]'
    c.summary = 'Generate docker-compose.yml and launch docker-compose'
    c.action do |args, options|
      generate_compose_file
      system 'docker-compose up'
    end
  end

  run!
end