Open nichtich opened 3 years ago
what about having a --config
parameter instead, to force alternative config resolution?
wb somecmd --config ./path/to/wb.config.a.json
wb somecmd --config ./path/to/wb.config.b.json
This would be helpful in some cases but would require to specify the config file with each call. I normally call wb
in sessions and/or scripts:
Switching accounts is already described as restoring a backup:
cp config.json.backup $(wd config path)
But this requires to know the config file location. $(dirname $(wd config path))
seems like a good place to put config files.
I can also solve this with a shell script such as (not tested):
DIR=$(dirname $(wd config path))
if [ -z "$1" ]; then
ls "$DIR"/config.*.json
else
CFG="$DIR/config.$1.json"
if [ -e "$CFG" ]; then
cp "$CFG" "$CFG" "$DIR/config.json"
fi
fi
But I thought this feature may also be of use for others.
that could work well with aliases
alias wda="wd --config ~/.config/wikibase-cli/config.a.json"
alias wdb="wd --config ~/.config/wikibase-cli/config.b.json"
wda set-label Q4115189 en foo
or we could look for the WB_CONFIG
environment variable, like we already do for WB_INSTANCE
and others
Working with multiple user accounts and configurations could be simplified. Right now I use something like
to switch between configuration $FOO and $BAR. I recommend to add commands:
to save current configuration to
$(dirname $(wd config path))/config.$name.json
andto select a named configuration (interactively if no name was specified).