Class: Shred::CLI

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



67
68
69
# File 'lib/shred.rb', line 67

def config
  @config
end

Class Method Details

.load_configObject



20
21
22
# File 'lib/shred.rb', line 20

def self.load_config
  @config = YAML.load(File.new('shred.yml'))
end

.set_up_commandsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/shred.rb', line 24

def self.set_up_commands
  if config.key?('commands')
    commands = config['commands']
    if commands.key?('platform_deps')
      desc 'platform_deps SUBCOMMAND ...ARGS', 'Manage platform dependencies'
      subcommand 'platform_deps', Commands::PlatformDeps
    end
    if commands.key?('services')
      desc 'services SUBCOMMAND ...ARGS', 'Control platform services'
      subcommand 'services', Commands::Services
    end
    if commands.key?('ruby_deps')
      desc 'ruby_deps SUBCOMMAND ...ARGS', 'Manage Ruby dependencies'
      subcommand 'ruby_deps', Commands::RubyDeps
    end
    if commands.key?('db')
      desc 'db SUBCOMMAND ...ARGS', 'Manage the database'
      subcommand 'db', Commands::Db
    end
    if commands.key?('dotenv')
      desc 'dotenv SUBCOMMAND ...ARGS', 'Manage the environmental configuration'
      subcommand 'dotenv', Commands::Dotenv
    end
    if commands.key?('test')
      desc 'test SUBCOMMAND ...ARGS', 'Run tests'
      subcommand 'test', Commands::Test
    end
    if commands.key?('app')
      desc 'app SUBCOMMAND ...ARGS', 'Control the application'
      subcommand 'app', Commands::App
    end
    if commands.key?('setup')
      desc 'setup', 'First-time application setup'
      def setup
        self.class.config['commands']['setup'].each do |cmd, subcmds|
          invoke(cmd.to_sym, subcmds.map(&:to_sym))
        end
      end
    end
  end
end

.startObject



14
15
16
17
18
# File 'lib/shred.rb', line 14

def self.start(*)
  load_config
  set_up_commands
  super
end