[augeas-devel] [PATCH 04/10] Expose aug_text_store in augtool and aug_srun
lutter at redhat.com
lutter at redhat.com
Tue May 22 00:44:31 UTC 2012
From: David Lutterkort <lutter at redhat.com>
---
src/augrun.c | 30 ++++++++++++++++++++++++++++++
src/augtool.c | 2 +-
2 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/src/augrun.c b/src/augrun.c
index e068859..f758b59 100644
--- a/src/augrun.c
+++ b/src/augrun.c
@@ -1014,6 +1014,35 @@ static const struct command_def cmd_insert_def = {
.help = cmd_ins_help
};
+static void cmd_store(struct command *cmd) {
+ const char *lens = arg_value(cmd, "lens");
+ const char *path = arg_value(cmd, "path");
+ const char *text = arg_value(cmd, "text");
+
+ aug_text_store(cmd->aug, lens, path, text, strlen(text));
+}
+
+static const struct command_opt_def cmd_store_opts[] = {
+ { .type = CMD_STR, .name = "lens", .optional = false,
+ .help = "the name of the lens" },
+ { .type = CMD_PATH, .name = "path", .optional = false,
+ .help = "where to store parsed text" },
+ { .type = CMD_STR, .name = "text", .optional = false,
+ .help = "the text to parse" },
+ CMD_OPT_DEF_LAST
+};
+
+static const char const cmd_store_help[] =
+ "Parse TEXT using LENS and store the resulting tree at PATH.";
+
+static const struct command_def cmd_store_def = {
+ .name = "store",
+ .opts = cmd_store_opts,
+ .handler = cmd_store,
+ .synopsis = "parse text into tree",
+ .help = cmd_store_help
+};
+
static const struct command_def const *commands[] = {
&cmd_quit_def,
&cmd_clear_def,
@@ -1035,6 +1064,7 @@ static const struct command_def const *commands[] = {
&cmd_setm_def,
&cmd_clearm_def,
&cmd_span_def,
+ &cmd_store_def,
&cmd_touch_def,
&cmd_help_def,
&cmd_def_last
diff --git a/src/augtool.c b/src/augtool.c
index 357fd4a..b4f7cc8 100644
--- a/src/augtool.c
+++ b/src/augtool.c
@@ -168,7 +168,7 @@ static char *readline_command_generator(const char *text, int state) {
"quit", "clear", "defnode", "defvar",
"get", "ins", "load", "ls", "match",
"mv", "print", "dump-xml", "rm", "save", "set", "setm",
- "clearm", "span", "help", NULL };
+ "clearm", "span", "store", "help", NULL };
static int current = 0;
const char *name;
--
1.7.7.6
More information about the augeas-devel
mailing list