Class: AppRb::Cli
- Inherits:
-
Object
- Object
- AppRb::Cli
- Defined in:
- lib/app-rb/cli.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Cli
Returns a new instance of Cli.
5 6 7 8 |
# File 'lib/app-rb/cli.rb', line 5 def initialize(args) @args = args Thread.abort_on_exception = true end |
Instance Method Details
#run ⇒ Object
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 36 37 38 39 40 41 |
# File 'lib/app-rb/cli.rb', line 10 def run if @args.count < 2 usage exit end config = Config.new(YAML.load(File.read(@args[0]))) command = @args[1] if AppRb::Util.compare_versions(config.tool_version, AppRb::VERSION) > 0 puts "FATAL: need at least '#{config.tool_version}' tool version but current version is '#{AppRb::VERSION}'" exit -1 end if command == "deploy" || command == "d" Command.new(config).deploy(@args[2]) elsif command == "status" || command == "s" Command.new(config).status elsif command == "redeploy" Command.new(config).redeploy elsif command == "clean" Command.new(config).clean elsif command == "stop" Command.new(config).stop elsif command == "run" || command == "r" Command.new(config).run(@args[2..-1].join(" ")) elsif command == "cd" Command.new(config).cd else puts "FATAL: unknown command '#{command}'" exit -1 end end |