Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Be resilient to unexpected CLI examples when deducing value syntax, f…
…ix 2.24 (#287) This fixes #284 and unblocks publishing docs for 2.24.x versions. It ensures the reference code-generation handles the new `-l` formatting syntax in the help-all output when extracting the example value. More generally, this PR makes this part of the code slightly: - more resilient by having it search for a CLI arg with syntax that can be understood, not just assuming the first one works - more debuggable by having an explicit error for the "can't find a value" case Background: our docs codegen formats a TOML snippet in, based on the information in the help-all output. This includes needing a representation of the argument value itself to deduce if it's an array or map, and also include in the output. This representation is deduced by looking after an `=` sign, e.g. `--level=<LogLevel>` => `<LogLevel>`. However, in pantsbuild/pants#21446 (released in 2.24.0.dev1), we fixed the help-all output to use the correct `-l<LogLevel>` syntax for that argument (previously it was formatted like `-l=<LogLevel>`, but passing `pants -l=debug ...` doesn't work, so this was misleading). This changes the `display_args` value for that option (see below) in a way that stops the argument-value-deduction from working. After this PR, the deduction now operates off the `--level=<LogLevel>` arg instead of `-l<LogLevel>`. - old: `["-l=<LogLevel>","--level=<LogLevel>"]` - new: `["-l<LogLevel>","--level=<LogLevel>"]`
- Loading branch information