You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2019/12/11 17:44:25 UTC

[mynewt-core] branch master updated: sys/config: Add "config delete" CLI command

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 7088a7c  sys/config: Add "config delete" CLI command
7088a7c is described below

commit 7088a7c029b5cc48efa079f5b6bb25e4a5414d24
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Dec 10 16:04:25 2019 -0800

    sys/config: Add "config delete" CLI command
    
    Add a "config delete" subcommand, e.g.
    
        config delete id/serial
    
    Note: config groups must implement correct delete behavior (do the right
    thing when a value is set to "").
---
 sys/config/src/config_cli.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/sys/config/src/config_cli.c b/sys/config/src/config_cli.c
index 582da55..87af242 100644
--- a/sys/config/src/config_cli.c
+++ b/sys/config/src/config_cli.c
@@ -117,22 +117,23 @@ shell_conf_command(int argc, char **argv)
         }
         console_printf("%s", val);
         return 0;
-    } else {
-        if (!strcmp(name, "dump")) {
-            if (!val || !strcmp(val, "running")) {
-                conf_dump_running();
-            }
+    } else if (!strcmp(name, "delete")) {
+        name = val;
+        val = "";
+    } else if (!strcmp(name, "dump")) {
+        if (!val || !strcmp(val, "running")) {
+            conf_dump_running();
+        }
 #if MYNEWT_VAL(CONFIG_CLI_DEBUG)
-            if (val && !strcmp(val, "saved")) {
-                conf_dump_saved();
-            }
+        if (val && !strcmp(val, "saved")) {
+            conf_dump_saved();
+        }
 #endif
+        return 0;
+    } else {
+        if (!strcmp(name, "save")) {
+            conf_save();
             return 0;
-        } else {
-            if (!strcmp(name, "save")) {
-                conf_save();
-                return 0;
-            }
         }
     }
     if (!val) {