Class: CI::Syntax::Tool::CommandLine
- Inherits:
-
Object
- Object
- CI::Syntax::Tool::CommandLine
- Defined in:
- lib/ci-syntax-tool/command_line.rb
Overview
CI::Syntax::Tool::CommandLine
a class to parse and represent the CLI options
also handles degenerate CLI cases, like --help,
--version, --list-languages, --list-formatters
Instance Attribute Summary collapse
-
#file_args ⇒ Object
readonly
Returns the value of attribute file_args.
-
#formatters ⇒ Object
readonly
Returns the value of attribute formatters.
-
#languages ⇒ Object
readonly
Returns the value of attribute languages.
-
#non_runnable_exit_status ⇒ Object
Returns the value of attribute non_runnable_exit_status.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ CommandLine
constructor
A new instance of CommandLine.
-
#runnable? ⇒ Boolean
rubocop: disable Style/TrivialAccessors.
Constructor Details
#initialize(args) ⇒ CommandLine
Returns a new instance of CommandLine.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ci-syntax-tool/command_line.rb', line 18 def initialize(args) @args = args.dup @runnable = true @non_runnable_exit_status = 0 @options = { languages: [], requires: [], formats: [], outputs: [], } @file_args = [] @parser = make_parser parse_args validate_file_args if runnable? load_requires if runnable? validate_languages if runnable? validate_formats if runnable? list_languages if runnable? && @options[:list_languages] list_formats if runnable? && @options[:list_formats] end |
Instance Attribute Details
#file_args ⇒ Object (readonly)
Returns the value of attribute file_args.
16 17 18 |
# File 'lib/ci-syntax-tool/command_line.rb', line 16 def file_args @file_args end |
#formatters ⇒ Object (readonly)
Returns the value of attribute formatters.
14 15 16 |
# File 'lib/ci-syntax-tool/command_line.rb', line 14 def formatters @formatters end |
#languages ⇒ Object (readonly)
Returns the value of attribute languages.
13 14 15 |
# File 'lib/ci-syntax-tool/command_line.rb', line 13 def languages @languages end |
#non_runnable_exit_status ⇒ Object
Returns the value of attribute non_runnable_exit_status.
12 13 14 |
# File 'lib/ci-syntax-tool/command_line.rb', line 12 def non_runnable_exit_status @non_runnable_exit_status end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/ci-syntax-tool/command_line.rb', line 15 def @options end |
Instance Method Details
#runnable? ⇒ Boolean
rubocop: disable Style/TrivialAccessors
43 44 45 |
# File 'lib/ci-syntax-tool/command_line.rb', line 43 def runnable? @runnable end |