prevent enabled command fallback to Python when it's run without --help

Summary:
I'm introducing a new Rust-only command implementation, and I never
want it to fall back to Python help, even if it's run without a
required option. Therefore, handle
DisplayHelpOnMissingArgumentOrSubcommand as well as DisplayHelp.

Reviewed By: fanzeyi

Differential Revision: D44560239

fbshipit-source-id: 43c418da3c980a34a11277c82bf350822b0bc71b
This commit is contained in:
Chad Austin 2023-03-31 11:08:05 -07:00 committed by Facebook GitHub Bot
parent c682ccc661
commit 56c1538580

View File

@ -183,7 +183,8 @@ fn wrapper_main() -> Result<i32> {
// UnknownArgument (whether or not --help was requested) and we
// should fall back to Python.
Err(e) => {
if e.kind() == clap::ErrorKind::DisplayHelp
if (e.kind() == clap::ErrorKind::DisplayHelp
|| e.kind() == clap::ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand)
&& should_use_rust_help(std::env::args(), &None).unwrap_or(false)
{
e.exit()