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

Read/write settings in XDG_CONFIG_HOME #49

Closed
xavdid opened this issue Jul 11, 2023 · 6 comments
Closed

Read/write settings in XDG_CONFIG_HOME #49

xavdid opened this issue Jul 11, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@xavdid
Copy link
Contributor

xavdid commented Jul 11, 2023

Describe the problem

When using the libby commands, the token is written to the local folder. This is convenient if you only work in a single folder, but it would be nice if followed the (fairly standard) XDG Base Directory convention. So, the default settings config (if not specified; you could keep the flag) would be ~/.config/odmpy.

You can put the settings there manually with the --settings flag, but it's annoying to type that for every operation.

Version/Environment

odmpy 0.7.9 [Python 3.11.3-darwin]
@ping
Copy link
Owner

ping commented Jul 11, 2023

Thanks for the suggestion.

But switching out the default settings folder now will likely break things for users that use the defaults (without explicitly specifying --settings), so that's a no-go for me.

odmpy looks to an env var named LIBBY_TOKEN for Libby authentication. You can find that value if you open libby.json in your settings folder and look for the identity value (should start with "eyJ"). If you set up LIBBY_TOKEN in env, odmpy will ignore the settings folder. This feature has not been documented and probably not heavily tested, so I'll be happy to take any bug reports if you wish to give it a try.

One more thing that may not help much in your case, but if you use the same set of command options often, you can put them in a config file and reference it.

odmpy libby @ex.conf

example.conf

@xavdid
Copy link
Contributor Author

xavdid commented Jul 11, 2023

But switching out the default settings folder now will likely break things for users that use the defaults (without explicitly specifying --settings), so that's a no-go for me.

I appreciate your commitment to stability. 😁 Assuming the default is currently your pwd, you could potentially ship this backwards-compatibly by checking first for a local settings file and falling back to the xdg dir if there's no auth file (or explicit flag). This way, existing users can continue to pick up local settings (if present), the flag still works, and new users get a better default.

Either way, the env var should work for my purposes. Feel free to close this if it's not something you're interested in.

@ping
Copy link
Owner

ping commented Jul 11, 2023

I actually like your suggestion, so I'll keep this open until I can get around to working on it.

@ping ping added the enhancement New feature or request label Jul 11, 2023
@ping
Copy link
Owner

ping commented Jul 13, 2023

This has been implemented on the master branch.

@xavdid
Copy link
Contributor Author

xavdid commented Jul 13, 2023

Thank you!

@ping
Copy link
Owner

ping commented Jul 18, 2023

Closing because this is now available from the latest v0.8.0 release.

@ping ping closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants