Class: Cliqr::Parser::ParsedInput Private

Inherits:
Object
  • Object
show all
Defined in:
lib/cliqr/parser/parsed_input.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A wrapper to keep the parsed input arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed_arguments) ⇒ ParsedInput

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a new parsed input



24
25
26
27
28
# File 'lib/cliqr/parser/parsed_input.rb', line 24

def initialize(parsed_arguments)
  @command = parsed_arguments[:command]
  @options = parsed_arguments[:options]
  @arguments = parsed_arguments[:arguments]
end

Instance Attribute Details

#argumentsArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

List of arguments from the command line

Returns:

  • (Array<String>)


21
22
23
# File 'lib/cliqr/parser/parsed_input.rb', line 21

def arguments
  @arguments
end

#commandString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Command name

Returns:

  • (String)


11
12
13
# File 'lib/cliqr/parser/parsed_input.rb', line 11

def command
  @command
end

#optionsHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Hash of options parsed from the command line

Returns:

  • (Hash)


16
17
18
# File 'lib/cliqr/parser/parsed_input.rb', line 16

def options
  @options
end

Instance Method Details

#==(other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test equality with another object

Returns:

  • (Boolean)

    true if this object is equal to other



58
59
60
# File 'lib/cliqr/parser/parsed_input.rb', line 58

def ==(other)
  eql?(other)
end

#default_action(action_config) ⇒ Symbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get name of default action if present as option

Returns:

  • (Symbol)

    Name of the default action or nil if not present



65
66
67
68
69
70
71
72
# File 'lib/cliqr/parser/parsed_input.rb', line 65

def default_action(action_config)
  if option('help') && action_config.help?
    return :help
  elsif option('version') && action_config.version?
    return :version
  end
  nil
end

#eql?(other) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Test equality with another object

Returns:

  • (Boolean)

    true if this object is equal to other



49
50
51
52
53
# File 'lib/cliqr/parser/parsed_input.rb', line 49

def eql?(other)
  self.class.equal?(other.class) &&
    @command == other.command &&
    @options == other.options
end

#option(name) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get a value of an option

Parameters:

  • name (String)

    Name of the option

Returns:

  • (String)


35
36
37
# File 'lib/cliqr/parser/parsed_input.rb', line 35

def option(name)
  @options[name.to_s]
end

#remove_option(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Remove a option

Returns:

  • (Object)

    Option’s original value



42
43
44
# File 'lib/cliqr/parser/parsed_input.rb', line 42

def remove_option(name)
  @options.delete(name.to_s)
end