Move position of 'list' subcommand.

It makes more sense in terms of ordering.
This commit is contained in:
Nicolás A. Ortega Froysa 2024-10-21 14:22:13 +02:00
parent d8a140e913
commit db0b607546
2 changed files with 6 additions and 6 deletions

View File

@ -25,8 +25,8 @@
enum cmd_id { enum cmd_id {
CMD_UNKNOWN = 0, CMD_UNKNOWN = 0,
CMD_ADD, CMD_ADD,
CMD_LIST,
CMD_DEL, CMD_DEL,
CMD_LIST,
CMD_INFO, CMD_INFO,
CMD_ADD_INGR, CMD_ADD_INGR,
CMD_RM_INGR, CMD_RM_INGR,
@ -38,8 +38,8 @@ enum cmd_id {
static const std::map<enum cmd_id, std::vector<std::string>> commands = { static const std::map<enum cmd_id, std::vector<std::string>> commands = {
{ CMD_ADD, {"add", "new"} }, { CMD_ADD, {"add", "new"} },
{ CMD_LIST, {"list", "ls"} },
{ CMD_DEL, {"del", "rm"} }, { CMD_DEL, {"del", "rm"} },
{ CMD_LIST, {"list", "ls"} },
{ CMD_INFO, {"info", "i"} }, { CMD_INFO, {"info", "i"} },
{ CMD_ADD_INGR, {"add-ingr"} }, { CMD_ADD_INGR, {"add-ingr"} },
{ CMD_RM_INGR, {"rm-ingr"} }, { CMD_RM_INGR, {"rm-ingr"} },
@ -63,8 +63,8 @@ static inline void print_help(void) {
std::cout << "COMMANDS:\n" std::cout << "COMMANDS:\n"
"\tadd, new Add a new recipe to the database.\n" "\tadd, new Add a new recipe to the database.\n"
"\tlist, ls List recipes with filters.\n"
"\tdel, rm Delete recipe by ID.\n" "\tdel, rm Delete recipe by ID.\n"
"\tlist, ls List recipes with filters.\n"
"\tinfo Show recipe information.\n" "\tinfo Show recipe information.\n"
"\tadd-ingr Add ingredient to a recipe.\n" "\tadd-ingr Add ingredient to a recipe.\n"
"\trm-ingr Remove ingredient from a recipe.\n" "\trm-ingr Remove ingredient from a recipe.\n"

View File

@ -41,12 +41,12 @@ int main(int argc, char *argv[]) {
case CMD_ADD: case CMD_ADD:
ret = cmd_add(); ret = cmd_add();
break; break;
case CMD_LIST:
ret = cmd_list(argc - 1, argv + 1);
break;
case CMD_DEL: case CMD_DEL:
ret = cmd_delete(argc - 2, argv + 2); ret = cmd_delete(argc - 2, argv + 2);
break; break;
case CMD_LIST:
ret = cmd_list(argc - 1, argv + 1);
break;
case CMD_INFO: case CMD_INFO:
ret = cmd_info(std::stoi(argv[2])); ret = cmd_info(std::stoi(argv[2]));
break; break;