mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Make 'nix dev-shell' a deprecated alias for 'nix develop'
This commit is contained in:
parent
61e3d598b6
commit
0f44b60e6d
4 changed files with 13 additions and 5 deletions
|
@ -217,10 +217,15 @@ MultiCommand::MultiCommand(const Commands & commands)
|
||||||
{
|
{
|
||||||
expectedArgs.push_back(ExpectedArg{"command", 1, true, [=](std::vector<std::string> ss) {
|
expectedArgs.push_back(ExpectedArg{"command", 1, true, [=](std::vector<std::string> ss) {
|
||||||
assert(!command);
|
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())
|
if (i == commands.end())
|
||||||
throw UsageError("'%s' is not a recognised command", ss[0]);
|
throw UsageError("'%s' is not a recognised command", cmd);
|
||||||
command = {ss[0], i->second()};
|
command = {cmd, i->second()};
|
||||||
}});
|
}});
|
||||||
|
|
||||||
categories[Command::catDefault] = "Available commands";
|
categories[Command::catDefault] = "Available commands";
|
||||||
|
|
|
@ -234,6 +234,8 @@ public:
|
||||||
|
|
||||||
std::map<Command::Category, std::string> categories;
|
std::map<Command::Category, std::string> categories;
|
||||||
|
|
||||||
|
std::map<std::string, std::string> deprecatedAliases;
|
||||||
|
|
||||||
// Selected command, if any.
|
// Selected command, if any.
|
||||||
std::optional<std::pair<std::string, ref<Command>>> command;
|
std::optional<std::pair<std::string, ref<Command>>> command;
|
||||||
|
|
||||||
|
|
|
@ -459,8 +459,7 @@ string base64Encode(const string & s);
|
||||||
string base64Decode(const string & s);
|
string base64Decode(const string & s);
|
||||||
|
|
||||||
|
|
||||||
/* Get a value for the specified key from an associate container, or a
|
/* Get a value for the specified key from an associate container. */
|
||||||
default value if the key doesn't exist. */
|
|
||||||
template <class T>
|
template <class T>
|
||||||
std::optional<typename T::mapped_type> get(const T & map, const typename T::key_type & key)
|
std::optional<typename T::mapped_type> get(const T & map, const typename T::key_type & key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -110,6 +110,8 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
|
||||||
.description = "consider all previously downloaded files out-of-date",
|
.description = "consider all previously downloaded files out-of-date",
|
||||||
.handler = {[&]() { refresh = true; }},
|
.handler = {[&]() { refresh = true; }},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
deprecatedAliases.insert({"dev-shell", "develop"});
|
||||||
}
|
}
|
||||||
|
|
||||||
void printFlags(std::ostream & out) override
|
void printFlags(std::ostream & out) override
|
||||||
|
|
Loading…
Reference in a new issue