Class: Bashly::Script::Argument
Instance Attribute Summary
Attributes inherited from Base
#options
Attributes included from Renderable
#render_options
Class Method Summary
collapse
Instance Method Summary
collapse
#validate, #validate?
Methods inherited from Base
#help, #initialize, #method_missing, #optional, #respond_to_missing?, #summary
Methods included from Renderable
#load_user_file, #render, #strings, #user_file_exist?, #user_file_path, #user_string, #view_marker
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Bashly::Script::Base
Class Method Details
.option_keys ⇒ Object
9
10
11
12
13
|
# File 'lib/bashly/script/argument.rb', line 9
def option_keys
@option_keys ||= %i[
allowed completions default help name repeatable required unique validate
]
end
|
Instance Method Details
#completion_dynamic ⇒ Object
30
31
32
|
# File 'lib/bashly/script/argument.rb', line 30
def completion_dynamic
completions&.fetch('dynamic', []) || []
end
|
#completion_options ⇒ Object
34
35
36
|
# File 'lib/bashly/script/argument.rb', line 34
def completion_options
completions&.fetch('options', []) || []
end
|
#completion_static ⇒ Object
26
27
28
|
# File 'lib/bashly/script/argument.rb', line 26
def completion_static
completions&.fetch('static', []) || []
end
|
#default_string ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/bashly/script/argument.rb', line 16
def default_string
if default.is_a?(Array)
Shellwords.shelljoin default
elsif default.is_a?(String) && repeatable
Shellwords.shellescape default
else
default
end
end
|
#label ⇒ Object
38
39
40
|
# File 'lib/bashly/script/argument.rb', line 38
def label
repeatable ? "#{name.upcase}..." : name.upcase
end
|
#usage_string ⇒ Object
42
43
44
|
# File 'lib/bashly/script/argument.rb', line 42
def usage_string
required ? label : "[#{label}]"
end
|