Class: AllGem::CLI
- Inherits:
-
Object
- Object
- AllGem::CLI
- Defined in:
- lib/all-gem/cli.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout:, stderr:, stdin:) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout:, stderr:, stdin:) ⇒ CLI
Returns a new instance of CLI.
26 27 28 29 30 31 32 |
# File 'lib/all-gem/cli.rb', line 26 def initialize(stdout:, stderr:, stdin:) @stdout = stdout @stderr = stderr @stdin = stdin set_optparse end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
24 25 26 |
# File 'lib/all-gem/cli.rb', line 24 def op @op end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
24 25 26 |
# File 'lib/all-gem/cli.rb', line 24 def opts @opts end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
24 25 26 |
# File 'lib/all-gem/cli.rb', line 24 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
24 25 26 |
# File 'lib/all-gem/cli.rb', line 24 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
24 25 26 |
# File 'lib/all-gem/cli.rb', line 24 def stdout @stdout end |
Instance Method Details
#run(argv) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/all-gem/cli.rb', line 34 def run(argv) argv = @op.order(argv) command = argv[0] or raise Error.new("COMMAND is not specified.\n\n" + op.help) spec = gemspec_from_command(command) versions = versions_of(spec, opts) versions = filter_by_level(versions, opts) install! spec, versions # TODO: omit the same output # TODO: handle exit status versions.each do |v| stdout.puts "#{command}-#{v}" __skip__ = system(command, "_#{v}_", *argv[1..]) end end |