commandFlags static method
Returns the sorted long names of the flags and options that were passed
on the command line, on the top level command and its subcommands
(e.g. ['--config-dir', '--project']).
Contains flag and option names only - never their values, since those can hold project ids and other user data.
Implementation
static List<String> commandFlags(final ArgResults topLevelResults) {
final flags = <String>[];
ArgResults? commandResults = topLevelResults;
while (commandResults != null) {
final results = commandResults;
flags.addAll(
results.options
.where(results.wasParsed)
.map((final option) => '--$option'),
);
commandResults = results.command;
}
flags.sort();
return flags;
}