Class: GemContribute::CLI::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_contribute/cli/config.rb

Overview

‘gem-contribute config <subcommand>`

Subcommands:

set <key> <value>   Write a value to ~/.config/gem-contribute/config.yml
get <key>           Print the current value of a key
list                Print all configured values

Constant Summary collapse

USAGE =
<<~USAGE
  Usage: gem-contribute config <subcommand>

  Subcommands:
    set <key> <value>    Set a configuration value.
    get <key>            Print the current value of a key.
    list                 Print all configured values.

  Keys:
    clone_root           Directory where forks are cloned (default: ~/code/oss).
                         Example: gem-contribute config set clone_root ~/Projects/oss
USAGE

Instance Method Summary collapse

Constructor Details

#initialize(stdout: $stdout, stderr: $stderr, config: GemContribute::Config.new) ⇒ Config

Returns a new instance of Config.



25
26
27
28
29
# File 'lib/gem_contribute/cli/config.rb', line 25

def initialize(stdout: $stdout, stderr: $stderr, config: GemContribute::Config.new)
  @stdout = stdout
  @stderr = stderr
  @config = config
end

Instance Method Details

#run(argv) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/gem_contribute/cli/config.rb', line 31

def run(argv)
  case argv.shift
  when "set"  then set(argv)
  when "get"  then get(argv)
  when "list" then list
  when nil, "help", "-h", "--help"
    @stdout.puts USAGE
    0
  else
    @stderr.puts "gem-contribute: unknown config subcommand"
    @stderr.puts USAGE
    2
  end
end