Class: FileReplicator::AbstractCmdParse

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

Direct Known Subclasses

JoinerCmdParse, SplitterCmdParse

Instance Method Summary collapse

Constructor Details

#initializeAbstractCmdParse

Returns a new instance of AbstractCmdParse.



11
12
13
# File 'lib/file_replicator/abstract_cmd_parse.rb', line 11

def initialize
  @colour = Pastel.new
end

Instance Method Details

#get_optionsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/file_replicator/abstract_cmd_parse.rb', line 15

def get_options
  options = parse_argv

  # display parameter list to let user know how to use them
  if ARGV.empty?
    puts options
    exit
  end

  validate options

  options
rescue MissingArgumentException,
    ArgumentError,
    Slop::MissingArgument,
    Slop::UnknownOption => e
  puts @colour.bright_red e.message
  exit 1
end

#header(txt) ⇒ Object



35
36
37
# File 'lib/file_replicator/abstract_cmd_parse.rb', line 35

def header(txt)
  @colour.yellow.bold.underline txt
end

#highlight(txt) ⇒ Object



39
40
41
# File 'lib/file_replicator/abstract_cmd_parse.rb', line 39

def highlight(txt)
  @colour.green.bold txt
end

#parse_argvObject



43
44
45
# File 'lib/file_replicator/abstract_cmd_parse.rb', line 43

def parse_argv
  raise 'Implementation missing'
end

#validate(options) ⇒ Object



47
48
49
# File 'lib/file_replicator/abstract_cmd_parse.rb', line 47

def validate(options)
  raise 'Implementation missing'
end