/*
* augrun.c: command interpreter for augeas
*
- * Copyright (C) 2011 David Lutterkort
+ * Copyright (C) 2011-2015 David Lutterkort
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
.help = cmd_transform_help
};
+static void cmd_load_file(struct command *cmd) {
+ const char *file = arg_value(cmd, "file");
+ int r = 0;
+
+ r = aug_load_file(cmd->aug, file);
+ if (r < 0)
+ ERR_REPORT(cmd, AUG_ECMDRUN,
+ "Failed to load file %s", file);
+}
+
+static const struct command_opt_def cmd_load_file_opts[] = {
+ { .type = CMD_PATH, .name = "file", .optional = false,
+ .help = "the file to load" },
+ CMD_OPT_DEF_LAST
+};
+
+static const char const cmd_load_file_help[] =
+ "Load a specific FILE, using autoload statements.\n";
+
+static const struct command_def cmd_load_file_def = {
+ .name = "load-file",
+ .opts = cmd_load_file_opts,
+ .handler = cmd_load_file,
+ .synopsis = "load a specific file",
+ .help = cmd_load_file_help
+};
+
static void cmd_save(struct command *cmd) {
int r;
r = aug_save(cmd->aug);
const char *last = err_get(aug, match, "lens/last_matched");
const char *next = err_get(aug, match, "lens/next_not_matched");
const char *msg = err_get(aug, match, "message");
+ const char *path = err_get(aug, match, "path");
const char *kind = NULL;
aug_get(aug, match, &kind);
if (line != NULL) {
fprintf(cmd->out, "Error in %s:%s.%s (%s)\n",
filename, line, char_pos, kind);
+ } else if (path != NULL) {
+ fprintf(cmd->out, "Error in %s at node %s (%s)\n", filename, path, kind);
} else {
fprintf(cmd->out, "Error in %s (%s)\n", filename, kind);
}
&cmd_save_def,
&cmd_store_def,
&cmd_transform_def,
+ &cmd_load_file_def,
&cmd_def_last
}
};