aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/args.hh
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-10-09 09:39:51 +0200
committerregnat <rg@regnat.ovh>2020-10-09 09:39:51 +0200
commit04e5d0e7040fdfbbc084634c0694ae7da89765d9 (patch)
tree23942b5586c03d62322989a88178237e104da00a /src/libutil/args.hh
parent58dadf295499588e492dab6bdc5934dc27ad3e64 (diff)
Add a description in the completion outputs
Make nix output completions in the form `completion\tdescription`. This can't be used by bash (afaik), but other shells like zsh or fish can display it along the completion choices
Diffstat (limited to 'src/libutil/args.hh')
-rw-r--r--src/libutil/args.hh12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index f41242e17..26f1bc11b 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -283,7 +283,17 @@ typedef std::vector<std::pair<std::string, std::string>> Table2;
void printTable(std::ostream & out, const Table2 & table);
-extern std::shared_ptr<std::set<std::string>> completions;
+struct Completion {
+ std::string completion;
+ std::string description;
+
+ bool operator<(const Completion & other) const;
+};
+class Completions : public std::set<Completion> {
+public:
+ void add(std::string completion, std::string description = "");
+};
+extern std::shared_ptr<Completions> completions;
extern bool pathCompletions;
std::optional<std::string> needsCompletion(std::string_view s);