#include "uci.h"
static const char *appname = "uci";
+static enum {
+ CLI_FLAG_MERGE = (1 << 0),
+} flags;
+static FILE *input = stdin;
static struct uci_context *ctx;
enum {
CMD_RENAME,
/* package cmds */
CMD_SHOW,
+ CMD_IMPORT,
CMD_EXPORT,
CMD_COMMIT,
};
fprintf(stderr,
"Usage: %s [<options>] <command> [<arguments>]\n\n"
"Commands:\n"
- "\texport [<config>]\n"
- "\tshow [<config>[.<section>[.<option>]]]\n"
- "\tget <config>.<section>[.<option>]\n"
- "\tset <config>.<section>[.<option>]=<value>\n"
+ "\texport [<config>]\n"
+ "\timport [<config>]\n"
+ "\tshow [<config>[.<section>[.<option>]]]\n"
+ "\tget <config>.<section>[.<option>]\n"
+ "\tset <config>.<section>[.<option>]=<value>\n"
+ "\trename <config>.<section>[.<option>]=<name>\n"
"\n"
"Options:\n"
- "\t-s force strict mode (stop on parser errors)\n"
- "\t-S disable strict mode\n"
+ "\t-f <file> use <file> as input instead of stdin\n"
+ "\t-m when importing, merge data into an existing package\n"
+ "\t-s force strict mode (stop on parser errors)\n"
+ "\t-S disable strict mode\n"
"\n",
argv[0]
);
return 0;
}
+static int uci_do_import(int argc, char **argv)
+{
+ return 0;
+}
+
static int uci_do_package_cmd(int cmd, int argc, char **argv)
{
char **configs = NULL;
cmd = CMD_RENAME;
else if (!strcasecmp(argv[0], "del"))
cmd = CMD_DEL;
+ else if (!strcasecmp(argv[0], "import"))
+ cmd = CMD_IMPORT;
else
cmd = -1;
case CMD_EXPORT:
case CMD_COMMIT:
return uci_do_package_cmd(cmd, argc, argv);
+ case CMD_IMPORT:
+ return uci_do_import(argc, argv);
default:
return 255;
}
while((c = getopt(argc, argv, "sS")) != -1) {
switch(c) {
+ case 'f':
+ input = fopen(optarg, "r");
+ if (!input) {
+ perror("uci");
+ return 1;
+ }
+ break;
+ case 'm':
+ flags |= CLI_FLAG_MERGE;
+ break;
case 's':
ctx->flags |= UCI_FLAG_STRICT;
break;
if (argc < 2)
uci_usage(argc, argv);
ret = uci_cmd(argc - 1, argv + 1);
+ if (input != stdin)
+ fclose(input);
if (ret == 255)
uci_usage(argc, argv);