/*
+ * cli - Command Line Interface for the Unified Configuration Interface
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify
static const char *appname = "uci";
static enum {
- CLI_FLAG_MERGE = (1 << 0),
- CLI_FLAG_QUIET = (1 << 1)
+ CLI_FLAG_MERGE = (1 << 0),
+ CLI_FLAG_QUIET = (1 << 1),
+ CLI_FLAG_NOCOMMIT = (1 << 2),
} flags;
static FILE *input;
CMD_SET,
CMD_DEL,
CMD_RENAME,
+ CMD_REVERT,
/* package cmds */
CMD_SHOW,
CMD_IMPORT,
"\tget <config>.<section>[.<option>]\n"
"\tset <config>.<section>[.<option>]=<value>\n"
"\trename <config>.<section>[.<option>]=<name>\n"
+ "\trevert <config>[.<section>[.<option>]]\n"
"\n"
"Options:\n"
"\t-f <file> use <file> as input instead of stdin\n"
return 0;
switch(cmd) {
case CMD_COMMIT:
+ if (flags & CLI_FLAG_NOCOMMIT)
+ return 0;
if (uci_commit(ctx, &p, false) != UCI_OK)
cli_perror();
break;
case CMD_RENAME:
ret = uci_rename(ctx, p, section, option, value);
break;
+ case CMD_REVERT:
+ ret = uci_revert(ctx, &p, section, option);
+ break;
case CMD_SET:
ret = uci_set(ctx, p, section, option, value);
break;
}
/* no save necessary for get */
- if (cmd == CMD_GET)
+ if ((cmd == CMD_GET) || (cmd == CMD_REVERT))
return 0;
/* save changes, but don't commit them yet */
else if (!strcasecmp(argv[0], "ren") ||
!strcasecmp(argv[0], "rename"))
cmd = CMD_RENAME;
+ else if (!strcasecmp(argv[0], "revert"))
+ cmd = CMD_REVERT;
else if (!strcasecmp(argv[0], "del"))
cmd = CMD_DEL;
else if (!strcasecmp(argv[0], "import"))
case CMD_SET:
case CMD_DEL:
case CMD_RENAME:
+ case CMD_REVERT:
return uci_do_section_cmd(cmd, argc, argv);
case CMD_SHOW:
case CMD_EXPORT:
case 'P':
uci_add_history_path(ctx, ctx->savedir);
uci_set_savedir(ctx, optarg);
+ flags |= CLI_FLAG_NOCOMMIT;
break;
case 'q':
flags |= CLI_FLAG_QUIET;