mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
nix --help: Show short flags
This commit is contained in:
parent
ddea253ff8
commit
1b0088ebb2
2 changed files with 6 additions and 4 deletions
|
@ -71,10 +71,11 @@ void Args::printHelp(const string & programName, std::ostream & out)
|
|||
void Args::printFlags(std::ostream & out)
|
||||
{
|
||||
Table2 table;
|
||||
for (auto & flags : longFlags)
|
||||
for (auto & flag : longFlags)
|
||||
table.push_back(std::make_pair(
|
||||
"--" + flags.first + renderLabels(flags.second.labels),
|
||||
flags.second.description));
|
||||
(flag.second.shortName ? std::string("-") + flag.second.shortName + ", " : " ")
|
||||
+ "--" + flag.first + renderLabels(flag.second.labels),
|
||||
flag.second.description));
|
||||
printTable(out, table);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ protected:
|
|||
/* Flags. */
|
||||
struct Flag
|
||||
{
|
||||
char shortName;
|
||||
std::string description;
|
||||
Strings labels;
|
||||
size_t arity;
|
||||
|
@ -63,7 +64,7 @@ public:
|
|||
const Strings & labels, const std::string & description,
|
||||
size_t arity, std::function<void(Strings)> handler)
|
||||
{
|
||||
auto flag = Flag{description, labels, arity, handler};
|
||||
auto flag = Flag{shortName, description, labels, arity, handler};
|
||||
if (shortName) shortFlags[shortName] = flag;
|
||||
longFlags[longName] = flag;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue