aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/args.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-18 21:38:15 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-18 21:38:15 +0000
commit40526fbea56a8006eb7f1758d461a5acbe9a1694 (patch)
tree5d74492a86f28fb7183897dc2a6d7baf2d24f7f1 /src/libutil/args.cc
parent6dd471ebf6b9a4996405398093ccb371b8abdf2f (diff)
parent6c000eed80565d83d596da800ca0db92e248342e (diff)
Merge remote-tracking branch 'upstream/master' into enum-class
Diffstat (limited to 'src/libutil/args.cc')
-rw-r--r--src/libutil/args.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc
index 4a3f5aae8..23e2d6227 100644
--- a/src/libutil/args.cc
+++ b/src/libutil/args.cc
@@ -45,7 +45,7 @@ void Args::parseCmdline(const Strings & _cmdline)
}
else if (!dashDash && std::string(arg, 0, 1) == "-") {
if (!processFlag(pos, cmdline.end()))
- throw UsageError(format("unrecognised flag '%1%'") % arg);
+ throw UsageError("unrecognised flag '%1%'", arg);
}
else {
pendingArgs.push_back(*pos++);
@@ -130,7 +130,7 @@ bool Args::processArgs(const Strings & args, bool finish)
{
if (expectedArgs.empty()) {
if (!args.empty())
- throw UsageError(format("unexpected argument '%1%'") % args.front());
+ throw UsageError("unexpected argument '%1%'", args.front());
return true;
}
@@ -217,10 +217,15 @@ MultiCommand::MultiCommand(const Commands & commands)
{
expectedArgs.push_back(ExpectedArg{"command", 1, true, [=](std::vector<std::string> ss) {
assert(!command);
- auto i = commands.find(ss[0]);
+ auto cmd = ss[0];
+ if (auto alias = get(deprecatedAliases, cmd)) {
+ warn("'%s' is a deprecated alias for '%s'", cmd, *alias);
+ cmd = *alias;
+ }
+ auto i = commands.find(cmd);
if (i == commands.end())
- throw UsageError("'%s' is not a recognised command", ss[0]);
- command = {ss[0], i->second()};
+ throw UsageError("'%s' is not a recognised command", cmd);
+ command = {cmd, i->second()};
}});
categories[Command::catDefault] = "Available commands";