Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facilitate switching users/config #132

Open
nichtich opened this issue Nov 9, 2020 · 6 comments
Open

Facilitate switching users/config #132

nichtich opened this issue Nov 9, 2020 · 6 comments

Comments

@nichtich
Copy link
Contributor

nichtich commented Nov 9, 2020

Working with multiple user accounts and configurations could be simplified. Right now I use something like

DIR=$(dirname $(wd config path)) wd config -j > $DIR/config.$FOO.json; ln -sf $DIR/config.$BAR.json $DIR/config.json

to switch between configuration $FOO and $BAR. I recommend to add commands:

wd config save <name>

to save current configuration to $(dirname $(wd config path))/config.$name.json and

wd config select [name]

to select a named configuration (interactively if no name was specified).

@maxlath
Copy link
Owner

maxlath commented Nov 9, 2020

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

@nichtich
Copy link
Contributor Author

nichtich commented Nov 9, 2020

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:

  • set config
  • perform some commands
  • switch config
  • perform some commands
  • ...

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.

@maxlath
Copy link
Owner

maxlath commented Nov 10, 2020

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

@maxlath
Copy link
Owner

maxlath commented Nov 10, 2020

or we could look for the WB_CONFIG environment variable, like we already do for WB_INSTANCE and others

@RogueScholar
Copy link

or we could look for the WB_CONFIG environment variable, like we already do for WB_INSTANCE and others

This is what I just came here looking for. If you were waiting to see how much demand there is for this, @maxlath, please add my name to the tally of proponents. 👍🏻

maxlath added a commit that referenced this issue Nov 20, 2024
maxlath added a commit that referenced this issue Nov 20, 2024
@maxlath
Copy link
Owner

maxlath commented Nov 20, 2024

So I implemented both the --config option and the WB_CONFIG env variable, see docs. Published in v18.3.0. Let me know if you encounter any problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants