/*
+ * 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;
"\t-m when importing, merge data into an existing package\n"
"\t-n name unnamed sections on export (default)\n"
"\t-N don't name unnamed sections\n"
+ "\t-p <path> add a search path for config change files\n"
+ "\t-P <path> add a search path for config change files and use as default\n"
"\t-q quiet mode (don't print error messages)\n"
"\t-s force strict mode (stop on parser errors, default)\n"
"\t-S disable strict mode\n"
cli_perror();
return 1;
}
+ if (!p)
+ 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;
cli_perror();
return 1;
}
+ if (!p)
+ return 0;
switch(cmd) {
case CMD_GET:
return 1;
}
- while((c = getopt(argc, argv, "mf:sSnNq")) != -1) {
+ while((c = getopt(argc, argv, "f:mnNp:P:sSq")) != -1) {
switch(c) {
case 'f':
input = fopen(optarg, "r");
case 'N':
ctx->flags &= ~UCI_FLAG_EXPORT_NAME;
break;
+ case 'p':
+ uci_add_history_path(ctx, optarg);
+ break;
+ 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;
break;