MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / composeUsage

Method composeUsage

src/commands/CmdHelp.cpp:180–231  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

178
179////////////////////////////////////////////////////////////////////////////////
180std::string CmdHelp::composeUsage() const {
181 Table view;
182 view.width(Context::getContext().getWidth());
183 view.add("");
184 view.add("");
185 view.add("");
186
187 // Static first row.
188 auto row = view.addRow();
189 view.set(row, 0, "Usage:");
190 view.set(row, 1, "task");
191 view.set(row, 2, "Runs rc.default.command, if specified.");
192
193 // Obsolete method of getting a list of all commands.
194 std::vector<std::string> all;
195 for (auto& cmd : Context::getContext().commands) all.push_back(cmd.first);
196
197 // Sort alphabetically by usage.
198 std::sort(all.begin(), all.end());
199
200 // Add the regular commands.
201 for (auto& name : all) {
202 if (name[0] != '_') {
203 row = view.addRow();
204 view.set(row, 1, Context::getContext().commands[name]->usage());
205 view.set(row, 2, Context::getContext().commands[name]->description());
206 }
207 }
208
209 // Add the helper commands.
210 for (auto& name : all) {
211 if (name[0] == '_') {
212 row = view.addRow();
213 view.set(row, 1, Context::getContext().commands[name]->usage());
214 view.set(row, 2, Context::getContext().commands[name]->description());
215 }
216 }
217
218 // Add the aliases commands.
219 row = view.addRow();
220 view.set(row, 1, " ");
221
222 for (auto& alias : Context::getContext().config) {
223 if (alias.first.substr(0, 6) == "alias.") {
224 row = view.addRow();
225 view.set(row, 1, alias.first.substr(6));
226 view.set(row, 2, format("Aliased to '{1}'", alias.second));
227 }
228 }
229
230 return view.render();
231}
232
233////////////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 7

widthMethod · 0.80
getWidthMethod · 0.80
setMethod · 0.80
usageMethod · 0.80
descriptionMethod · 0.80
addMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected