From ec14d7df7cfec676bf74a73a6b0a2db1b2f874b3 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Thu, 25 Nov 2021 16:51:11 +0100 Subject: [PATCH] nmcli: introduce "add" command to edit mode This patch introduces "add" command to nmcli edit mode. When using "add" it will append the value to the ones already set. This is doing the same thing than the "set" command does right now. Example: ``` nmcli> add ipv4.addresses 192.168.1.1/24 ``` --- src/nmcli/connections.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 831e5bfc5f..ed5b6450ab 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -6726,6 +6726,7 @@ typedef enum { NMC_EDITOR_MAIN_CMD_HELP, NMC_EDITOR_MAIN_CMD_NMCLI, NMC_EDITOR_MAIN_CMD_QUIT, + NMC_EDITOR_MAIN_CMD_ADD, } NmcEditorMainCmd; static void @@ -6776,6 +6777,8 @@ parse_editor_main_cmd(const char *cmd, char **cmd_arg) editor_cmd = NMC_EDITOR_MAIN_CMD_REMOVE; else if (matches(cmd_arg0, "set")) editor_cmd = NMC_EDITOR_MAIN_CMD_SET; + else if (matches(cmd_arg0, "add")) + editor_cmd = NMC_EDITOR_MAIN_CMD_ADD; else if (matches(cmd_arg0, "describe")) editor_cmd = NMC_EDITOR_MAIN_CMD_DESCRIBE; else if (matches(cmd_arg0, "print")) @@ -6857,6 +6860,11 @@ editor_main_help(const char *command) "This command sets property value.\n\n" "Example: nmcli> set con.id My connection\n")); break; + case NMC_EDITOR_MAIN_CMD_ADD: + g_print(_("add [. ] :: add property value\n\n" + "This command appends property value.\n\n" + "Example: nmcli> add ipv4.addresses 192.168.1.1/24\n")); + break; case NMC_EDITOR_MAIN_CMD_DESCRIBE: g_print(_("describe [.] :: describe property\n\n" "Shows property description. You can consult nm-settings(5) " @@ -7727,6 +7735,7 @@ editor_menu_main(NmCli *nmc, NMConnection *connection, const char *connection_ty split_editor_main_cmd_args(cmd_arg, &cmd_arg_s, &cmd_arg_p, &cmd_arg_v); switch (cmd) { + case NMC_EDITOR_MAIN_CMD_ADD: case NMC_EDITOR_MAIN_CMD_SET: /* Set property value */ if (!cmd_arg) {