72 Commits

Author SHA1 Message Date
Rylan Polster
b7b624c9bf
parser: clarify errors for invalid number of args 2021-01-23 15:06:44 -05:00
Seeker
50cd836427
Merge pull request #10351 from SeekingMeaning/sig-braces
rubocop: require braces for Sorbet `sig`
2021-01-19 03:50:20 -08:00
Rylan Polster
1e4fef8123
usage string generator: fix handling of dashed-commands 2021-01-18 21:20:12 -05:00
Rylan Polster
a9a0c415e7
Cleanup usage strings for flags 2021-01-18 21:20:11 -05:00
Rylan Polster
6f69aab6cf
Cleanup usage string
Include only global args and list the specific options if there are two or fewer.
2021-01-18 21:20:11 -05:00
Rylan Polster
b7977244ea
parser: automatically generate usage banners 2021-01-18 21:16:24 -05:00
Seeker
fbafaff4fe rubocop: require braces for Sorbet sig 2021-01-18 16:52:45 -08:00
Rylan Polster
eebc161ea5 Incorporate suggestions from code review
Co-Authored-By: Seeker <meaningseeking@protonmail.com>
2021-01-15 00:13:30 -05:00
Rylan Polster
3af16832d9 Generate bash completions automatically 2021-01-15 00:03:28 -05:00
Rylan Polster
74c1010256 parser: add tests for named methods 2021-01-14 15:14:10 -05:00
Rylan Polster
da811373d3 Add named_args DSL for commands 2021-01-13 17:09:42 -05:00
Rylan Polster
ab97c30b14 cli/parser: use - instead of _ in cask args 2020-12-25 12:42:18 -05:00
Issy Long
531cae4b8c
cli/parser: Option-ify arg names when raising OptionConstraintError
- There's already a method on `CLI::Parser`, we don't need to hand-roll
  the "number of dashes" detection.

Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2020-12-24 16:52:39 +00:00
Issy Long
27afcf5779
cli/parser: Improve single or multi "-" detection
- This reads nicer (to me).
2020-12-24 15:54:24 +00:00
Issy Long
570a660758
cli/parser: Only prefix short options with one dash
- This avoids error messages like:

```
➜ brew list -l
Error: Invalid usage: `--l` cannot be passed without `--formula`.
```
2020-12-24 13:33:37 +00:00
Seeker
8fc478fef1 cli: fix underlined multi-line help text 2020-12-18 20:54:34 -08:00
EricFromCanada
9dec442e71 pr-pull: prepare replacement for --workflow flag 2020-12-11 16:50:03 -05:00
EricFromCanada
b7aae0c643
parser: allow a disabled switch to specify its replacement 2020-12-01 12:02:44 +00:00
Markus Reiter
1b9002c04a Fix type errors in postinstall. 2020-11-29 21:23:54 +01:00
Mike McQuaid
caae165eb2
Improve brew install --quiet
- Suppress (some more) warnings when doing `brew install --quiet`
- Clarify `man brew` output that we don't suppress all warnings
  for all commands with `--quiet`

While I was doing this I noticed references to the (soon to be
deprecated) `brew switch` so:
- remove these references in `install` output
- remove a reference in the documentation
- add a comment to remind me to deprecate `brew diy`, too

Fixes #9179
2020-11-18 10:13:57 +00:00
Markus Reiter
0184e271d8 Fix RuboCop offenses. 2020-11-17 11:09:55 +01:00
EricFromCanada
f784b7107f manpage: fixes for grammar 2020-11-16 07:56:50 -05:00
EricFromCanada
eb16624c5f manpage: reformat lists of subcommands & env vars
Modify parser.rb to add a colon between each term and the line break, which `ronn` converts into a definition list.
The <br> that follows ensures each term description is on a new line in the manpage output, and also replaces the
double trailing space for generating the hard return that follows each term in the HTML output.
Also modify man.rb to print environment variables with list markup matching the cask commands, and then drop
trailing colons from both lists of terms (cask commands, env vars) and non-list terms (analytics, bundle, services;
a <br> is added here because it would prevent the term description from being indented in the manpage output).
https://docs.brew.sh/Manpage#cask-command-options-cask
2020-11-16 07:56:50 -05:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Jonathan Chang
ab7b757400 rubocop: fix Style/NegatedIfElseCondition 2020-11-10 23:28:31 +11:00
Mike McQuaid
438874af3c
list: more parameters fixes.
- Remove incorrect `--formula` requirements.
- Fix bad `OptionConstraintError` output message.

Fixes #9037.
2020-11-03 16:50:03 +00:00
Mike McQuaid
5adb76a5ba
list: fix flag handling.
Fix `-1` and other flags so they're handled correctly with casks. Use
the "right" exceptions for declaring invalid combinations and change
their parent class so that `--help` is printed nicely too.

Fixes #9033
2020-11-03 12:29:58 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
d6b563e752 Support min_named :formula_or_cask. 2020-10-08 11:12:17 +02:00
Markus Reiter
7743fed77b Add “GLOBAL CASK OPTIONS” section to man page. 2020-10-08 11:07:35 +02:00
Markus Reiter
2ee30b8067 Refactor MinNamedArgumentsError and MaxNamedArgumentsError. 2020-10-08 11:06:04 +02:00
Mike McQuaid
2e5272d04c Deprecate/disable code for Homebrew 2.5.0.
Do the usual "disable deprecations" and "uncomment pending deprecations"
dance and delete/deprecate/disable relevant/related code.
2020-09-03 10:34:22 +01:00
Bo Anderson
e3372e2a14 Lazily require some heavy files 2020-08-20 02:05:17 +01:00
Markus Reiter
4c833b241d Fix parsing of negative options. 2020-08-14 20:03:15 +02:00
Markus Reiter
b48bc316e0 Use CLI::Parser for cask commands. 2020-08-13 05:15:15 +02:00
Markus Reiter
9d6350037f Use try instead of send. 2020-08-06 16:13:14 +02:00
Bo Anderson
5e98d4df08 cli/parser: restore env setting for global options 2020-08-01 17:36:16 +01:00
Markus Reiter
0de9eb0382 Rename split_double_dash to split_non_options. 2020-07-31 17:46:54 +02:00
Markus Reiter
be2d19fe07 Refactor handling of formula options in CLI::Parser. 2020-07-31 17:46:54 +02:00
Markus Reiter
4381c32524 Add test for parsing with ignore_invalid_options. 2020-07-31 15:07:17 +02:00
Markus Reiter
d4c2ffd705 Refactor CLI::Parser. 2020-07-31 15:07:17 +02:00
Markus Reiter
24eff8f81a Pass args in SoftwareSpec instead of using global args. 2020-07-30 03:21:12 +02:00
Markus Reiter
c0d42dd922 Remove --force from global_options. 2020-07-28 10:31:11 +02:00
Markus Reiter
bf13db3367 Make Parser#parse return args. 2020-07-25 02:37:10 +02:00
Jonathan Chang
76709d82c5 Fix brew style. 2020-07-13 23:24:14 +10:00
Mike McQuaid
ef95b59ed4
Remove HomebrewArgvExtension
Fixes #5730
2020-05-23 19:39:11 +01:00
Mike McQuaid
4f75a77b08
Update deprecations
Add more deprecations, disable deprecations and remove disabled code.
2020-05-18 13:50:46 +01:00
Mike McQuaid
af278b15de
cli/parser: add formulae method.
This removes the coupling on args.formulae before it has been parsed.
2020-05-10 15:10:36 +01:00
Mike McQuaid
c91f397605
cli: fix options handling.
Fix breaking options on taps again (second time in two weeks, sob).

To avoid doing this again: also add a test for this case (that I've
verified would have caught these cases).
2020-05-07 10:33:02 +01:00
Mike McQuaid
20a1199375
Refactor CLI to remove unless args_parsed
Refactor the CLI::Args module so it doesn't have different paths to
check arguments depending on whether the arguments have been parsed or
not. Instead, set the values we need from the global ARGV at
first, global initialisation time where they will be thrown away when
the actual arguments are parsed.

To do this some other general refactoring was needed:
- more methods made private when possible
- e.g. `HEAD?` used consistently instead of `head` before arguments
  are parsed.
- formula options are only parsed after named arguments are extracted
2020-05-05 17:47:51 +01:00