lib/percheron/commands/abstract.rb in percheron-0.6.4 vs lib/percheron/commands/abstract.rb in percheron-0.7.0
- old
+ new
@@ -1,34 +1,46 @@
module Percheron
module Commands
class Abstract < Clamp::Command
- DEFAULT_CONFIG_FILE = '.percheron.yml'
+ option([ '-c', '--config_file' ], 'CONFIG', 'Config file',
+ default: Config::DEFAULT_CONFIG_FILE)
- option [ '-c', '--config_file' ], 'CONFIG', 'Configuration file', default: DEFAULT_CONFIG_FILE
-
- option '--version', :flag, 'show version' do
+ option('--version', :flag, 'show version') do
puts Percheron::VERSION
exit(0)
end
def self.default_parameters!
- parameter('STACK_NAME', 'stack name', required: false)
- parameter('CONTAINER_NAMES', 'container names', required: false, default: []) do |container_names|
+ parameter('STACK_NAME', 'stack name', required: true)
+ parameter('CONTAINER_NAMES', 'container names', default: [],
+ required: false) do |container_names|
container_names.split(/,/)
end
end
+ def self.default_create_parameters!
+ default_parameters!
+ option('--start', :flag, 'Start container', default: false)
+ end
+
+ def execute
+ stack.valid?
+ rescue => e
+ signal_usage_error(e.message)
+ end
+
def stack
+ return NullStack.new if stack_name.nil?
Percheron::Stack.new(config, stack_name)
end
def default_config_file
- ENV.fetch('PERCHERON_CONFIG', DEFAULT_CONFIG_FILE)
+ ENV.fetch('PERCHERON_CONFIG', Config::DEFAULT_CONFIG_FILE)
end
def config
- @config ||= Percheron::Config.new(config_file)
+ @config ||= Percheron::Config.load!(config_file)
rescue Errors::ConfigFileInvalid => e
$logger.error e.message
exit(1)
end
end