lib/negroku/cli.rb in negroku-1.0.0 vs lib/negroku/cli.rb in negroku-1.1.0
- old
+ new
@@ -1,8 +1,9 @@
require 'thor'
require 'rainbow'
require 'highline/import'
+require 'negroku'
trap('INT') { exit }
class App < Thor
@@ -155,14 +156,15 @@
end
end
class RemoteEnv < Thor
namespace "env"
+ class_option :stage, :type => :string, :default => "staging", :aliases => "-s", :desc => "Set the capistrano stage to be used", :banner => "STAGE"
desc "show", "Show the current remote variables"
def show
- `cap rbenv:vars:show`
+ %x(cap #{options[:stage]} rbenv:vars:show)
end
desc "add", "Adds env variables to the remote server"
method_option :local, :type => :boolean, :aliases => "-l"
def add(key=nil, value=nil)
@@ -190,15 +192,27 @@
key = ask("Please enter the variable key:")
value = ask("Please enter the value for #{key}:")
end
end
- `cap rbenv:vars:add -s key=#{key} -s value=#{value}`
+ %x(cap #{options[:stage]} rbenv:vars:add -s key=#{key} -s value=#{value})
end
end
module Negroku
class CLI < Thor
+ class_option :version, :type => :boolean, :aliases => "-v"
+
+ def initialize(*)
+ super
+
+ # Show the version
+ if options[:version]
+ puts Negroku::VERSION
+ exit 0
+ end
+ end
+
register(App, 'app', 'app [COMMAND]', 'Application')
register(Target, 'target', 'target [COMMAND]', 'Target servers')
register(Konfig, 'config', 'config [COMMAND]', 'Configuration')
register(RemoteEnv, 'env', 'env [COMMAND]', 'Remote environmental variables')
end