MCPcopy Create free account
hub / github.com/DFHack/dfhack / alias

Method alias

library/Commands.cpp:346–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344 }
345
346 command_result Commands::alias(color_ostream& con, Core& core, const std::string& first, const std::vector<std::string>& parts)
347 {
348 if (parts.size() >= 3 && (parts[0] == "add" || parts[0] == "replace"))
349 {
350 const std::string& name = parts[1];
351 std::vector<std::string> cmd(parts.begin() + 2, parts.end());
352 if (!core.AddAlias(name, cmd, parts[0] == "replace"))
353 {
354 con.printerr("Could not add alias {} - already exists\n", name);
355 return CR_FAILURE;
356 }
357 }
358 else if (parts.size() >= 2 && (parts[0] == "delete" || parts[0] == "clear"))
359 {
360 if (!core.RemoveAlias(parts[1]))
361 {
362 con.printerr("Could not remove alias {}\n", parts[1]);
363 return CR_FAILURE;
364 }
365 }
366 else if (parts.size() >= 1 && (parts[0] == "list"))
367 {
368 auto aliases = core.ListAliases();
369 for (auto p : aliases)
370 {
371 con << p.first << ": " << join_strings(" ", p.second) << std::endl;
372 }
373 }
374 else
375 {
376 con << "Usage: " << std::endl
377 << " alias add|replace <name> <command...>" << std::endl
378 << " alias delete|clear <name> <command...>" << std::endl
379 << " alias list" << std::endl;
380 }
381
382 return CR_OK;
383 }
384
385 command_result Commands::fpause(color_ostream& con, Core& core, const std::string& first, const std::vector<std::string>& parts)
386 {

Callers 1

RenameSquadFunction · 0.80

Calls 7

AddAliasMethod · 0.80
RemoveAliasMethod · 0.80
ListAliasesMethod · 0.80
join_stringsFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected