MCPcopy Create free account
hub / github.com/WasmVM/WasmVM / help

Function help

src/exec/CommandParser.cpp:14–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "color.hpp"
13
14static void help(std::filesystem::path program, std::string desc,
15 std::vector<std::variant<CommandParser::Fixed, CommandParser::Optional>> options
16){
17 std::cerr << desc << std::endl;
18 // Usage
19 std::cerr << std::endl << "Usage: " << program.filename().string() << " [-h | --help]";
20 bool showed_dashdash = false;
21 for(std::variant<CommandParser::Fixed, CommandParser::Optional> option : options){
22 std::visit(overloaded {
23 [&](CommandParser::Fixed& opt){
24 if(!showed_dashdash){
25 std::cerr << " [--]";
26 showed_dashdash = true;
27 }
28 std::cerr << " " << opt.name;
29 switch(opt.number){
30 case (unsigned)-1:
31 std::cerr << "...";
32 break;
33 case 0:
34 case 1:
35 break;
36 default:
37 std::cerr << "{" << opt.number << "}";
38 break;
39 }
40 },
41 [&](CommandParser::Optional& opt){
42 std::cerr << " [";
43 if(!opt.alias.empty()){
44 std::cerr << opt.alias << " | ";
45 }
46 std::cerr << opt.name << "]";
47 switch(opt.number){
48 case (unsigned)-1:
49 std::cerr << "...";
50 break;
51 case 0:
52 break;
53 case 1:
54 std::cerr << "?";
55 break;
56 default:
57 std::cerr << "{" << opt.number << "}";
58 break;
59 }
60 }
61 }, option);
62 }
63
64 // Options
65 std::cerr << std::endl << std::endl << "Options:" << std::endl;
66 std::cerr << " --help, -h\t\tShow help message" << std::endl;
67 std::cerr << " --\t\t\tEnd of options; remaining arguments are positional" << std::endl;
68 for(auto& option : options){
69 std::visit(overloaded {
70 [&](CommandParser::Fixed& opt){
71 std::cerr << " " << opt.name << "\t\t" << opt.desc << std::endl;

Callers 1

CommandParserMethod · 0.85

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected