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

Method handleArg0

src/CLI2.cpp:307–327  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Arg0 is the first argument, which is the name and potentially a relative or absolute path to the invoked binary. The binary name is 'task', but if the binary is reported as 'cal' or 'calendar' then it was invoked via symbolic link, in which case capture the first argument as 'calendar'.

Source from the content-addressed store, hash-verified

305// 'calendar' then it was invoked via symbolic link, in which case capture the
306// first argument as 'calendar'.
307void CLI2::handleArg0() {
308 // Capture arg0 separately, because it is the command that was run, and could
309 // need special handling.
310 auto raw = _original_args[0].attribute("raw");
311 A2 a(raw, Lexer::Type::word);
312 a.tag("BINARY");
313
314 std::string basename = "task";
315 auto slash = raw.rfind('/');
316 if (slash != std::string::npos) basename = raw.substr(slash + 1);
317
318 a.attribute("basename", basename);
319 if (basename == "cal" || basename == "calendar") {
320 _args.push_back(a);
321
322 A2 cal("calendar", Lexer::Type::word);
323 _args.push_back(cal);
324 } else {
325 _args.push_back(a);
326 }
327}
328
329////////////////////////////////////////////////////////////////////////////////
330// All arguments must be individually and wholly recognized by the Lexer. Any

Callers

nothing calls this directly

Calls 2

attributeMethod · 0.80
tagMethod · 0.80

Tested by

no test coverage detected