Module: Bashly::Script::Introspection::Arguments

Included in:
Command
Defined in:
lib/bashly/script/introspection/arguments.rb

Instance Method Summary collapse

Instance Method Details

#argsObject

Returns an array of Arguments



6
7
8
9
10
11
12
# File 'lib/bashly/script/introspection/arguments.rb', line 6

def args
  return [] unless options['args']

  options['args'].map do |options|
    Argument.new options
  end
end

#default_argsObject

Returns an array of all the default Args



15
16
17
# File 'lib/bashly/script/introspection/arguments.rb', line 15

def default_args
  args.select(&:default)
end

#repeatable_arg_exist?Boolean

Returns true if one of the args is repeatable

Returns:

  • (Boolean)


20
21
22
# File 'lib/bashly/script/introspection/arguments.rb', line 20

def repeatable_arg_exist?
  args.any?(&:repeatable)
end

#required_argsObject

Returns an array of all the required Arguments



25
26
27
# File 'lib/bashly/script/introspection/arguments.rb', line 25

def required_args
  args.select(&:required)
end

#usage_string_argsObject

Returns an array of args usage_string for the command’s usage_string



30
31
32
# File 'lib/bashly/script/introspection/arguments.rb', line 30

def usage_string_args
  args.map(&:usage_string)
end

#whitelisted_argsObject

Returns an array of all the args with a whitelist



35
36
37
# File 'lib/bashly/script/introspection/arguments.rb', line 35

def whitelisted_args
  args.select(&:allowed)
end