[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/augtool.c: new 'defvar' command



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=f14e32d980fe181e0199655a5f3797016cf0568a
Commit:        f14e32d980fe181e0199655a5f3797016cf0568a
Parent:        dcadae4d5f4276baaadb5bc51fe0d779b029bf9b
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Thu Mar 19 22:34:34 2009 -0700
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Tue Mar 24 15:54:01 2009 -0700

* src/augtool.c: new 'defvar' command

---
 src/augtool.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/augtool.c b/src/augtool.c
index f7ea46e..9b1d772 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -194,6 +194,17 @@ static int cmd_set(char *args[]) {
     return r;
 }
 
+static int cmd_defvar(char *args[]) {
+    const char *name = args[0];
+    const char *path = cleanpath(args[1]);
+    int r;
+
+    r = aug_defvar(aug, name, path);
+    if (r == -1)
+        printf ("Failed\n");
+    return r;
+}
+
 static int cmd_clear(char *args[]) {
     const char *path = cleanpath(args[0]);
     int r;
@@ -392,6 +403,11 @@ static const struct command const commands[] = {
     { "load", 0, 0, cmd_load, "load",
       "Load files accordig to the transforms in /augeas/load."
     },
+    { "defvar", 2, 2, cmd_defvar, "defvar <NAME> <EXPR>",
+      "Define the variable NAME to the result of evalutating EXPR. The\n"
+      "        variable can be used in path expressions as $NAME. Note that EXPR\n"
+      "        is evaluated when the variable is defined, not when it is used."
+    },
     { "help", 0, 0, cmd_help, "help",
       "Print this help text"
     },



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]