diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-21 14:58:32 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-04-21 14:58:32 +0200 |
commit | 69e3ffb076931aba73b5fcc41f5264f5f62c5ce9 (patch) | |
tree | f01268866200955342848abb27f044c17359ca6b /src/nix/command.cc | |
parent | 1b0088ebb226ab80c91b54c201cc70204b976310 (diff) |
nix --help: Show usage examples
Diffstat (limited to 'src/nix/command.cc')
-rw-r--r-- | src/nix/command.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nix/command.cc b/src/nix/command.cc index 986953fd8..c8d91737d 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) { |