MCPcopy Create free account
hub / github.com/alibaba/MNN / MakeUsage

Function MakeUsage

apps/mnncli/src/cli_command_spec.cpp:116–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116std::string MakeUsage(const CommandSpec& spec) {
117 std::ostringstream oss;
118 oss << "Usage: mnncli " << spec.name;
119
120 // Show positional arguments
121 if (spec.max_positional > 0) {
122 oss << " [";
123 if (spec.max_positional == 1) {
124 oss << "model_name";
125 } else {
126 oss << "model_name ...";
127 }
128 oss << "]";
129 }
130
131 // Show options
132 if (!spec.options.empty()) {
133 oss << " [options]";
134 }
135
136 oss << "\n\n";
137
138 // Help text
139 if (!spec.help.empty()) {
140 oss << spec.help << "\n\n";
141 }
142
143 // Options
144 if (!spec.options.empty()) {
145 oss << "Options:\n";
146 for (const auto& opt : spec.options) {
147 oss << " ";
148 if (opt.short_name) {
149 oss << "-" << opt.short_name << ", ";
150 }
151 oss << "--" << opt.long_name;
152
153 if (opt.kind == ArgKind::Value) {
154 oss << " <value>";
155 }
156
157 if (opt.required) {
158 oss << " (required)";
159 }
160
161 oss << " " << opt.help << "\n";
162 }
163 }
164
165 return oss.str();
166}
167
168} // namespace mnncli

Callers 4

RunMethod · 0.85
HandleMethod · 0.85
PrintRunUsageMethod · 0.85
HandleMethod · 0.85

Calls 2

emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected