hipcheck
hipcheck copied to clipboard
chore (cli): Changes hc CLI to use compile-time "derive" syntax
This changes the CLI for the hc command to use clap's "derive" syntax over the previous "build" syntax. This makes the CLI run at compile-time, which will save time when Hipcheck is run on different data sources without recompilation in between (as we expect) with typical use.
As a bonus feature, the CLI no longer panics if no command argument is provided. Instead it displays the appropriate help text, as expected.
Turns out I had already fixed the panic w/o arguments issue, but I was testing with an older build.
Annoyingly, the test passes when I run it locally.
Test is likely failing because we are trying to have our cake and eat it too with respect to our help command.
The current version of the CLI implements a custom help text that works on either the -h/--help flag or the help subcommand (as well as calling hc without any arguments). Despite renaming the flag and turning off default help, we are still failing this test.
Options are:
- Figure out a way to pass the test
- Delete the test, because it is more harm than help at this point
- Get rid of the
--helpflag, because we already have two other ways to get the help text.
@mchernicoff taking a look now. I rebased on the latest main, including fixing a conflict, and also added a new CI step to see the full cargo tree output to help debug this and future CI issues. This does mean the remote branch has been force pushed and can't just be pull-ed. If you have un-pushed local work let me know, happy to help with Git issues.
The specific assert that's causing the test to fail is here: https://github.com/clap-rs/clap/blob/master/clap_builder/src/builder/debug_asserts.rs#L334-L339
Basically, it's running through all subcommands from the .get_subcommands() method and panicking if it finds any duplicates. In this case it's saying that the help subcommand is duplicated.
Unfortunately I haven't been able to duplicate this in CI myself. Will keep working on it.