Class: RubyPatchesMerger::Cli

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Cli

Returns a new instance of Cli.



10
11
12
# File 'lib/ruby_patches_merger/cli.rb', line 10

def initialize(args)
  @args = args.map{|arg| arg.split(/[ ,]/)}.flatten
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/ruby_patches_merger/cli.rb', line 3

def args
  @args
end

Class Method Details

.run(args) ⇒ Object



5
6
7
8
# File 'lib/ruby_patches_merger/cli.rb', line 5

def self.run(args)
  cli = new(args)
  cli.run
end

Instance Method Details

#help(message = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_patches_merger/cli.rb', line 14

def help(message = nil)
  puts message if message
  puts <<HELP
Usage: ruby_patches_merger [download|help]

 - download revisions,list
 - help

HELP
end

#runObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ruby_patches_merger/cli.rb', line 25

def run
  case args[0]
  when 'download'
    require 'ruby_patches_merger/revisions'
    RubyPatchesMerger::Revisions.new(args[1..-1]).save_to("patches")
  when nil, 'help', '--help'
    help
  else
    help "Unknown arguments given '#{args*" "}'."
  end
end