Class: SugoiAliasesUpdator::Cli

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

Constant Summary collapse

COMMANDS =
%w(add rm del list show)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Cli

Returns a new instance of Cli.



7
8
9
10
11
12
# File 'lib/sugoi_aliases_updator/cli.rb', line 7

def initialize(args)
  @filepath =         args[0] || ''
  @command =          args[1]
  @target_email =     args[2]
  @direction_labels = args[3]
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

#filepathObject (readonly)

Returns the value of attribute filepath.



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

def filepath
  @filepath
end

#target_emailObject (readonly)

Returns the value of attribute target_email.



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

def target_email
  @target_email
end

Instance Method Details

#check_inputObject



14
15
16
17
18
19
20
# File 'lib/sugoi_aliases_updator/cli.rb', line 14

def check_input
  display_version
  check_filepath
  check_command
  check_terget_email
  check_direction
end

#direction_labelsObject



22
23
24
25
# File 'lib/sugoi_aliases_updator/cli.rb', line 22

def direction_labels
  raise("Oops '#{@direction_labels}'") unless /(TO|FROM)=(.*)$/ =~ @direction_labels
  $2.split(/,\s?/)
end