diff options
author | Rafał Miłecki <rafal@milecki.pl> | 2021-04-12 16:05:52 +0200 |
---|---|---|
committer | Rafał Miłecki <rafal@milecki.pl> | 2021-04-14 08:15:46 +0200 |
commit | 4b3db1179747b6a6779029407984bacef851325c (patch) | |
tree | 24ea933c1d98b6a200a89e37b272b15a0a22e28a | |
parent | 52bbc99f69ea6f67b6fe264f424dac91bde5016c (diff) | |
download | uci-4b3db1179747b6a6779029407984bacef851325c.tar.gz |
cli: add option for changing save path
Save path is a directory where config change (delta) files are stored.
Having a custom individual save dir can be used to prevent two (or more)
"uci" cli callers (e.g. bash scripts) from commiting each other changes.
In the following example:
App0 App1
---- ----
uci set system.@system[0].timezone=UTC
uci set system.@system[0].hostname=OpenWrt
uci commit system
App1 would unintentionally commit changes made by App0. This can be
avoided by at least 1 "uci" cli user specifying a custom -t option.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r-- | cli.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -167,6 +167,7 @@ static void uci_usage(void) "\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-t <path> set save path for config change files\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" @@ -706,7 +707,7 @@ int main(int argc, char **argv) return 1; } - while((c = getopt(argc, argv, "c:d:f:LmnNp:P:sSqX")) != -1) { + while((c = getopt(argc, argv, "c:d:f:LmnNp:P:qsSt:X")) != -1) { switch(c) { case 'c': uci_set_confdir(ctx, optarg); @@ -754,6 +755,9 @@ int main(int argc, char **argv) case 'q': flags |= CLI_FLAG_QUIET; break; + case 't': + uci_set_savedir(ctx, optarg); + break; case 'X': flags &= ~CLI_FLAG_SHOW_EXT; break; |