Class: Gift::Cli

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, stdin) ⇒ Cli

Returns a new instance of Cli.



17
18
19
20
21
22
23
24
25
# File 'lib/cli.rb', line 17

def initialize(arguments, stdin)
  @arguments = arguments
  @stdin = stdin

  # Set defaults
  @options = OpenStruct.new
  @options.verbose = false
  @options.quiet = false
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/cli.rb', line 15

def options
  @options
end

Instance Method Details

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cli.rb', line 27

def run
  if parsed_options?
    puts "Start at #{DateTime.now}\n\n" if @options.verbose
    
    output_options if @options.verbose # [Optional]

    process_arguments            
    process_command
    
    puts "\nFinished at #{DateTime.now}" if @options.verbose
  else
    output_usage
  end
  
  return 0
end