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

Logfile config does not work #713

Open
rixx opened this issue Feb 6, 2019 · 2 comments
Open

Logfile config does not work #713

rixx opened this issue Feb 6, 2019 · 2 comments
Labels

Comments

@rixx
Copy link

@rixx rixx commented Feb 6, 2019

I'm trying to make mycli run without creating a ~/.mycli.log.

mycli --logfile=~/.cache/mycli.log complained that this file or directory did not exist, despite its existance. No ~ expansion?

mycli --logfile=/home/rixx/.cache/mycli.log again creates ~/.mycli.log.

@tsroten tsroten added the bug label Feb 7, 2019
@tsroten
Copy link
Member

@tsroten tsroten commented Feb 7, 2019

@rixx Hello! Thanks for reporting this. So, this appears to be an odd behavior related to how the library we use to parse the command-line arguments works. I think this is definitely worth fixing. For now, here is a workaround.

You can edit your mycli config file (defaults to ~/.myclirc) and set the audit_log config option to ~/.cache/mycli.log. I actually do something similar with my mycli config.

As for fixing this going forward, it looks like we need to change this from a click.File to click.Path. Marking as a bug 😄

@Hanaasagi
Copy link

@Hanaasagi Hanaasagi commented Apr 8, 2019

@tsroten. When run

mycli mysql://root@10.6.112.32:3306 --logfile=~/mycli.log

will get

Error: Invalid value for "-l" / "--logfile": Could not open file: ~/mycli.log: No such file or directory

But run

mycli mysql://root@10.6.112.32:3306 --logfile ~/mycli.log

It will be ok.

~ is normally expanded by the shell. If use --logfile=~/mycli.log, it will not trigger. I find that someone wants to using os.path.expanduser to solve this problem in Click, but the pull request was rejected. Please see pallets/click#229.

And click.Path will not work too.

@tsroten tsroten added the easy label May 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.