nix --help: Show usage examples
This commit is contained in:
		
							parent
							
								
									1b0088ebb2
								
							
						
					
					
						commit
						69e3ffb076
					
				
					 3 changed files with 41 additions and 0 deletions
				
			
		|  | @ -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) | ||||
| { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue