Class: Rem2ics::CLI

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

Overview

The rem2ics command.

Streams are injected rather than assumed, so the whole command is testable without shelling out or capturing $stdout.

Defined Under Namespace

Classes: Options

Constant Summary collapse

EXIT_SUCCESS =
0
EXIT_FAILURE =
1
EXIT_USAGE =
2
STDIN =

Remind reads standard input under this name; so does this.

"-"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out: $stdout, err: $stderr) ⇒ CLI

Returns a new instance of CLI.



33
34
35
36
# File 'lib/rem2ics/cli.rb', line 33

def initialize(out: $stdout, err: $stderr)
  @out = out
  @err = err
end

Instance Attribute Details

#errObject (readonly)

Returns the value of attribute err.



31
32
33
# File 'lib/rem2ics/cli.rb', line 31

def err
  @err
end

#outObject (readonly)

Returns the value of attribute out.



31
32
33
# File 'lib/rem2ics/cli.rb', line 31

def out
  @out
end

Instance Method Details

#call(argv) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rem2ics/cli.rb', line 38

def call(argv)
  options = Options.new(
    paths:     [],
    today:     Date.today,
    horizon:   Recurrence::DEFAULT_HORIZON,
    organizer: nil,
  )

  dispatch(parse(argv, options), options)
rescue OptionParser::ParseError, Date::Error => error
  err.puts(error.message)
  EXIT_USAGE
end