Class: PlugemsDeploy::Cli
- Inherits:
-
Object
- Object
- PlugemsDeploy::Cli
- Defined in:
- lib/plugems_deploy/cli.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
The array of (unparsed) command-line options.
-
#options ⇒ Object
readonly
The hash of (parsed) command-line options.
Class Method Summary collapse
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(args = ARGV) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(args = ARGV) ⇒ Cli
Returns a new instance of Cli.
18 19 20 21 22 23 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 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/plugems_deploy/cli.rb', line 18 def initialize(args = ARGV) @args = args = { :version => '> 0.0', :deps_only => false, :debug => false } OptionParser.new do |opts| opts. = "Usage: #{$0} [options] ACTION ARGS" opts.separator "" opts.separator "Options -----------------------" opts.separator "" opts.on("-v", "--version VERSION", "The gem version to use. Any valid gem spec", "version expression can be specified." ) { |value| [:version] = value } opts.on("-o", "--only-dependencies", "Update only gem dependencies but not itself." ) { [:deps_only] = true } opts.on("-d", "--debug", "Prints some additional debug information." ) { [:debug] = true } opts.on("-h", "--help", "Display this help message") do puts opts exit end opts.separator "" opts.separator "Actions -----------------------" opts.separator "" opts.separator "push -- pushes gems to the base gem server\npublish -- builds a gem from the current directory and pushes it to the base gem server\nbuild -- builds a gem from the current directory\nupdate -- updates gems from the local gem server\nget -- updates gems from the local gem server for dependencies defined in config/manifest.yml\n".split(/\n/) if args.empty? $stderr.puts opts exit(-1) else opts.parse!(args) @opts = opts end end if args.size < 1 $stderr.puts @opts exit(-1) end [:action] = args.shift [:name] = args.shift end |
Instance Attribute Details
#args ⇒ Object (readonly)
The array of (unparsed) command-line options
13 14 15 |
# File 'lib/plugems_deploy/cli.rb', line 13 def args @args end |
#options ⇒ Object (readonly)
The hash of (parsed) command-line options
16 17 18 |
# File 'lib/plugems_deploy/cli.rb', line 16 def end |
Class Method Details
.execute! ⇒ Object
8 9 10 |
# File 'lib/plugems_deploy/cli.rb', line 8 def self.execute! new.execute! end |
Instance Method Details
#execute! ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/plugems_deploy/cli.rb', line 77 def execute! begin process_aliases validate_arguments rescue => ex puts "Invalid arguments: #{ ex }" exit(-1) end begin Capistrano::CLI.new(converted_arguments).execute! rescue Exception => ex if [:debug] raise else puts "Failed to execute: #{ ex }" exit(-1) end end end |