Class: KXI::CLI::Argument

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

Overview

Represents argument of command-line interface

Direct Known Subclasses

AnonymousArgument, ExplicitArgument

Instance Method Summary collapse

Constructor Details

#initialize(nm, desc, req, order) ⇒ Argument

Instantiates the KXI::CLI::Argument class

Parameters:

  • nm (String)

    Name of argument

  • desc (String)

    Description of argument

  • req (Bool)

    Determines whether argument is mandatory

  • order (Number)

    Order of argument

Raises:

  • (Exception)


48
49
50
51
52
53
54
# File 'lib/kxi/cli/argument.rb', line 48

def initialize(nm, desc, req, order)
	raise(Exception.new('Invalid argument name!')) unless /^[A-Za-z0-9\-]+$/m =~ nm
	@name  = nm.downcase
	@desc  = desc
	@req   = req
	@order = order
end

Instance Method Details

#descriptionString

Gets the description of argument

Returns:

  • (String)

    Description of argument



27
28
29
# File 'lib/kxi/cli/argument.rb', line 27

def description
	@desc
end

#headlineString

Gets full descriptive name of argument

Returns:

  • (String)

    Full name of argument



21
22
23
# File 'lib/kxi/cli/argument.rb', line 21

def headline
	name
end

#nameString

Gets the name of argument

Returns:

  • (String)

    Name of argument



9
10
11
# File 'lib/kxi/cli/argument.rb', line 9

def name
	@name
end

#orderNumber

Gets the order of argument (in descending order)

Returns:

  • (Number)

    Order of argument



39
40
41
# File 'lib/kxi/cli/argument.rb', line 39

def order
	@order
end

#required?Bool

Indicates whether argument is mandatory

Returns:

  • (Bool)

    True if argument is mandatory; otherwise false



33
34
35
# File 'lib/kxi/cli/argument.rb', line 33

def required?
	@req
end

#syntaxString

Gets syntax of argument

Returns:

  • (String)

    Syntax of argument



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

def syntax
	name
end