Class: Pvectl::ArgvPreprocessor
- Inherits:
-
Object
- Object
- Pvectl::ArgvPreprocessor
- Defined in:
- lib/pvectl/argv_preprocessor.rb
Overview
Command line argument preprocessor.
Normalizes ARGV arguments before passing to GLI by reordering flags to appear before positional arguments, using GLI command metadata for dynamic flag discovery.
GLI with ‘subcommand_option_handling :normal` requires flags before positional arguments. This preprocessor allows kubectl-style flag placement anywhere on the command line.
Defined Under Namespace
Classes: DuplicateFlagError
Constant Summary collapse
- MAX_ARGUMENTS =
Returns Maximum number of arguments (DoS protection).
10_000- MAX_ARGUMENT_LENGTH =
Returns Maximum length of single argument in bytes.
4096- PASSTHROUGH_FLAGS =
Returns Flags passed through without processing.
%w[--help -h --version].freeze
Class Method Summary collapse
-
.process(argv, cli_app: Pvectl::CLI) ⇒ Array<String>
Processes command line arguments.
Instance Method Summary collapse
-
#call ⇒ Array<String>
Executes argument processing.
-
#initialize(argv, cli_app: Pvectl::CLI) ⇒ ArgvPreprocessor
constructor
Initializes preprocessor with a copy of arguments.
Constructor Details
#initialize(argv, cli_app: Pvectl::CLI) ⇒ ArgvPreprocessor
Initializes preprocessor with a copy of arguments.
63 64 65 66 |
# File 'lib/pvectl/argv_preprocessor.rb', line 63 def initialize(argv, cli_app: Pvectl::CLI) @argv = argv.dup @cli_app = cli_app end |
Class Method Details
Instance Method Details
#call ⇒ Array<String>
Executes argument processing.
73 74 75 76 77 78 79 |
# File 'lib/pvectl/argv_preprocessor.rb', line 73 def call validate_input_limits! return @argv if passthrough_mode? return [] if @argv.empty? reorder_all_flags end |