From 69e3ffb076931aba73b5fcc41f5264f5f62c5ce9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 21 Apr 2016 14:58:32 +0200 Subject: nix --help: Show usage examples --- src/nix/command.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/nix/command.cc') diff --git a/src/nix/command.cc b/src/nix/command.cc index 986953fd845d..c8d91737d8be 100644 --- a/src/nix/command.cc +++ b/src/nix/command.cc @@ -5,6 +5,21 @@ namespace nix { Commands * RegisterCommand::commands = 0; +void Command::printHelp(const string & programName, std::ostream & out) +{ + Args::printHelp(programName, out); + + auto exs = examples(); + if (!exs.empty()) { + out << "\n"; + out << "Examples:\n"; + for (auto & ex : exs) + out << "\n" + << " " << ex.description << "\n" // FIXME: wrap + << " $ " << ex.command << "\n"; + } +} + MultiCommand::MultiCommand(const Commands & _commands) : commands(_commands) { -- cgit 1.4.1