Skip to content

Commit

Permalink
Handle invocations like cvd -h or cvd --help
Browse files Browse the repository at this point in the history
Treating it at `cvd help` uses existing logic, rather than trying to
force the handling into selectors parsing or handle it as a "driver"
flag (how `verbosity` is handled in `main`).

The selector flags are already processed by this point and do not
interfere.

Bug: 387539609
Test: cvd -h
Test: cvd --help
Test: cvd -help version
Test: cvd --instance_name=test -h
Test: cvd --selector_typo=test -h
  • Loading branch information
cjreynol committed Jan 30, 2025
1 parent 9037acc commit 2837246
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/cvd/cuttlefish/host/commands/cvd/cli/command_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <vector>

#include "common/libs/utils/files.h"
#include "common/libs/utils/flag_parser.h"
#include "common/libs/utils/result.h"
#include "host/commands/cvd/cli/command_request.h"
#include "host/commands/cvd/cli/selector/selector_common_parser.h"
Expand All @@ -44,6 +45,12 @@ CommandRequest::CommandRequest(cvd_common::Args args, cvd_common::Envs env,
subcommand_ = subcommand_arguments_[0];
subcommand_arguments_.erase(subcommand_arguments_.begin());
}

// transform `cvd -h` or `cvd --help` requests into `cvd help`
Result<bool> is_top_level_help_flag = HasHelpFlag({subcommand_});
if (is_top_level_help_flag.ok() && *is_top_level_help_flag) {
subcommand_ = "help";
}
}

CommandRequestBuilder& CommandRequestBuilder::AddArguments(
Expand Down

0 comments on commit 2837246

Please sign in to comment.