insanum / sncli

Simplenote CLI
MIT License
396 stars 34 forks source link

gracefully handle config file errors #75

Closed samuelallan72 closed 5 years ago

samuelallan72 commented 5 years ago

Comments/suggestions welcome.

N0ury commented 5 years ago

@swalladge

ericbrandwein commented 5 years ago

I haven't yet either, maybe later

samuelallan72 commented 5 years ago
* fix unhelpful crash traceback when no password given... => this is a
  workaround (OK) What's the original use if cfg_sn_password_eval?

This isn't a workaround. This is fixing a bug (I had forgot to add a default value for this config option so attempting to access it when not in config file resulted in an exception).

cfg_sn_password_eval is used as an alternative to hardcoding the password in the config file by specifying a command to run to retrieve the password (eg. from a keyring).

I haven't yet decided what to do if no password or password_eval found yet. Do you reckon the current behaviour is ok? (simply the status message at the top of the screen)

N0ury commented 5 years ago

For me it's ok. It's much better than an exception.

It would also be nice if you could explain the cfg_sn_password_eval behaviour in the doc. A small example would be a plus. I like this way of using passwords. Changing them becomes easier.

samuelallan72 commented 5 years ago

@nbenm it already is in the readme in the configuration section:

# as an alternate to cfg_sn_password you could use the following config item
# any shell command can be used; its stdout is used for the password
# trailing newlines are stripped for ease of use
# note: if both password config are given, cfg_sn_password will be used
cfg_sn_password_eval = gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.sncli-pass.gpg

Perhaps it should be mentioned higher up?

samuelallan72 commented 5 years ago

@ericbrandwein can you confirm if this branch solves the issue for you? :)

N0ury commented 5 years ago

Ah, yes. I haven't seen it. So it's all good. I'm going to try this version. I'll tell you if you can merge it.

ericbrandwein commented 5 years ago

I'm sorry for not answering until now, @swalladge I can confirm this solves the issue. It would be nice if it asked for the user and password instead of just saying "Config file not found", but that I guess is something for a different Issue.

samuelallan72 commented 5 years ago

Great! :) Yes, I'm not sure how to go about prompting for username/password. Since it should work in non-interactive mode for some things (eg. backing up, importing via scripts, etc.) prompting for input would be undesirable. Perhaps it could prompt only when in interactive mode.

N0ury commented 5 years ago

Sorry but I don't understand. Doing pip3 install sncli, installs old version, the one without the "file not found" message. I've tried to uninstall and then reinstall, it's the same.

samuelallan72 commented 5 years ago

Yes that's correct. Pip installs from the latest release on PyPi by default. If you would like to install the latest from git master, try something like:

pip3 install git+https://github.com/insanum/sncli.git
N0ury commented 5 years ago

Thanks. It works fine this way.

Le 27 nov. 2018 à 23:56:28, Samuel Walladge notifications@github.com a écrit :

Yes that's correct. Pip installs from the latest release on PyPi by default. If you would like to install the latest from git master, try something like:

pip3 install git+https://github.com/insanum/sncli.git

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.