Class: KXI::CLI::ExplicitArgument

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

Overview

Represents argument specified explicitly with name

Direct Known Subclasses

FlagArgument, NamedArgument

Instance Method Summary collapse

Methods inherited from Argument

#description, #name, #order, #required?

Constructor Details

#initialize(nm, desc, sh = nil, req = false) ⇒ ExplicitArgument

Instantiates the KXI::CLI::ExplicitArgument class

Parameters:

  • nm (String)

    Name of argument

  • desc (String)

    Description of argument

  • sh (String, nil) (defaults to: nil)

    Shortcut of argument

  • req (Bool) (defaults to: false)

    Specifies whether argument is mandatory



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

def initialize(nm, desc, sh = nil, req = false)
	super(nm, desc, req, req ? 2 : 1)
	@sh = sh
end

Instance Method Details

#headlineString

Gets full descriptive name of argument

Returns:

  • (String)

    Full name of argument



9
10
11
12
13
14
# File 'lib/kxi/cli/explicit_argument.rb', line 9

def headline
	ret = ''
	ret = "-#{@sh}, " if @sh != nil
	ret += "--#{name}"
	return ret
end

#shortcutString

Gets the shortcut symbol of argument

Returns:

  • (String)

    Shortcut symbol of argument



24
25
26
# File 'lib/kxi/cli/explicit_argument.rb', line 24

def shortcut
	@sh
end

#syntaxString

Gets syntax of argument

Returns:

  • (String)

    Syntax of argument



18
19
20
# File 'lib/kxi/cli/explicit_argument.rb', line 18

def syntax
	headline
end