Skip to content

cvd: Better help for load and start subcommands#2605

Open
jemoreira wants to merge 7 commits into
google:mainfrom
jemoreira:flags
Open

cvd: Better help for load and start subcommands#2605
jemoreira wants to merge 7 commits into
google:mainfrom
jemoreira:flags

Conversation

@jemoreira
Copy link
Copy Markdown
Member

Added a default implementation of DetailedHelp that prints in the same format for all commands (unless they override it, which most still do):

cvd `CmdList()[0]` - `SummaryHelp()`

`Description()`

`Flags()`

Both load and start make use of that default implementation.

Added more information and missing flags to both command's help output.

Some QoL improvements to the load command.

jemoreira added 7 commits May 22, 2026 17:41
New virtual functions for description and flags are added to the base
command handler class, with default implementation since not all
subcommands implement them yet.

The default implementation of DetailedHelp will ensure all help messages
will have the same style.
Not all command handlers will be able to use the default help
implementation. They can still reuse some of the lower level utitlities
by exposing those in a library.
By adding a marker to the string that the helper removes, but otherwise
leaves the input string unmodified.
Use the default DetailedHelp implmentation for consistent formatting.

Add more details to the help text.
The credential_source and project_id flags are parsed into respective
string fields, only to later add them to the overrides list. This change
makes the setter and getter of those flags interact with the overrides
list directly.

Assisted-by: Gemini:Next
Overriding the same property in the same instance is likely an error, so
it's best to fail than produce unexpected results for the user.
@jemoreira jemoreira requested a review from Databean May 23, 2026 00:48
@jemoreira jemoreira enabled auto-merge May 23, 2026 00:48
Comment on lines +40 to +41
// This implementation will break each paragraph in lines not longer than 80
// characters.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This implementation" sounds like it refers to the default implementation of Description(), but that doesn't make sense: Description() doesn't have anything to do with formatting.

The comment is really referring to the default implementation of DetailedHelp, so the comment should say that instead.

Comment on lines +69 to +71
// Make sure the flags are in alphabetical order
std::sort(flags.begin(), flags.end(),
[](auto f1, auto f2) { return f1.Name() < f2.Name(); });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth defining operator< on flags, or at least a public function CompareName(const Flag&, const Flag&).

}

std::string MarkAsRawText(std::string_view str) {
return std::string(kRawTextMark).append(str);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: absl::StrCat

)

cf_cc_library(
name = "help_helpers",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format_help or help_format?

std::string config_path;
std::string credential_source;
std::string project_id;
std::map<std::string, std::string> overrides;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this was std::map<std::string, std::string, std::less<void>>, it would be possible to use methods like operator[] or find with std::string_view arguments.

Comment on lines +180 to +181
// Test Setter
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests added in this file look like they could be easily split up into multiple tests around these blocks. The only shared state is in the load_flags variable, and IMO the getter test would be easier to read if it didn't rely on the setter test running first.

- "<absolute_path>")"),

"If the build value starts with \"@ab\", cvd will fetch the specified "
"Android build target from the Android build servers. By default it "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: two spaces between "Android" and "build"

Comment on lines +280 to +286
"cuttlefish/host/commands/cvd/cli/parser/load_config.proto.",

"While most config file properties are self explanatory, the build "

"properties (default_build, kernel.build, bootloader.build, etc) require "

"more explanation. These properties support two types of values:",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: odd blank lines here?

Comment on lines +512 to +522
"The `cvd start` command applies to the instance group, not specific "
"instances because Cuttlefish instances in the same group must all be "
"started (and stopped) in unisom. The group to be started is chosen "
"using the standard selector flags.",
"Flags that modify individual instances accept a comma separated list of "
"values. If the number of values in one of these flags is less than the "
"number of instances, then the last instances in the group will default "
"to the first value in the list (as a result a single value provided "
"applies to all instances). The empty string is interpreted as a valid "
"value, to force a particular instance to use its intended default value "
"the special value \"unset\" must be given."};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe use a R"(...)" string here?

Result<std::string> LoadConfigsCommand::DetailedHelp(
std::vector<std::string> LoadConfigsCommand::Description() const {
return {
"This command is an alias of `cvd create --config_file=<config_filepath> "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe use R"(...)" strings even for the non-MarkAsRawText help strings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants