Class: AllGem::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/all-gem/cli.rb

Defined Under Namespace

Classes: Error, Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, stderr:, stdin:) ⇒ CLI

Returns a new instance of CLI.



27
28
29
30
31
32
33
# File 'lib/all-gem/cli.rb', line 27

def initialize(stdout:, stderr:, stdin:)
  @stdout = stdout
  @stderr = stderr
  @stdin = stdin

  set_optparse
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



25
26
27
# File 'lib/all-gem/cli.rb', line 25

def op
  @op
end

#optsObject (readonly)

Returns the value of attribute opts.



25
26
27
# File 'lib/all-gem/cli.rb', line 25

def opts
  @opts
end

#stderrObject (readonly)

Returns the value of attribute stderr.



25
26
27
# File 'lib/all-gem/cli.rb', line 25

def stderr
  @stderr
end

#stdinObject (readonly)

Returns the value of attribute stdin.



25
26
27
# File 'lib/all-gem/cli.rb', line 25

def stdin
  @stdin
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



25
26
27
# File 'lib/all-gem/cli.rb', line 25

def stdout
  @stdout
end

Instance Method Details

#run(argv) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/all-gem/cli.rb', line 35

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

  execute_and_print argv, versions
end