Init more carefully and accept enter to terminate user name input#18
Init more carefully and accept enter to terminate user name input#18arvidj merged 7 commits intoahrefs:masterfrom
Conversation
thatportugueseguy
left a comment
There was a problem hiding this comment.
looks good, just some minor nitpicks wrt the terms used
lib/commands.ml
Outdated
| input; | ||
| Buffer.contents buf | ||
| match In_channel.input_line stdin with | ||
| | None -> die "E: EOF while reading user name." |
There was a problem hiding this comment.
Maybe some more user-friendly message? 😅
There was a problem hiding this comment.
Hmm, sure! I'm not sure what is more friendly though. You can make this error appear by pressing Ctrl-D in the terminal with no input. Or by redirecting /dev/null to the process:
$ dune exec bin/main.exe -- init --force
Welcome to passage initial setup.
...
What should be the name used for your recipient identity?
E: Passage init failed: Failure("E: username input was terminated by EOF before a newline was encountered. Ensure the username is newline-terminated and try again")
perhaps it should just say:
E: Passage init failed: Empty user name.
?
There was a problem hiding this comment.
yes, that makes more sense and is understandable by non-techies :)
There was a problem hiding this comment.
Ok, see latest version!
Note that I also moved the try/catch around a bit (here: 56797b9). Before, if we couldn't read the username for some reason, we would remove the config dir (granted that --force had been passed). I changed the code s.t. the config dir is only removed if we actually read the user name successfully and so had started writing to the config dir. This seems a bit more gentle, and less risk for data loss. Makes sense to you?
lib/commands.ml
Outdated
| let line = String.trim line in | ||
| let buf = Buffer.create String.(length line) in |
There was a problem hiding this comment.
| let line = String.trim line in | |
| let buf = Buffer.create String.(length line) in | |
| let buf = Buffer.create String.(length (trim line)) in |
There was a problem hiding this comment.
IIUC The var line is read below by String.iter, so if I trim as you suggested initial whitespace would be changed to _ instead of trimmed.
There was a problem hiding this comment.
ah, you're right, i missed that usage. 👍
I agree on this one. Probably better on another PR, given the scope? |
Co-authored-by: José Nogueira <thatportugueseguy@users.noreply.github.com>
102d520 to
72ac00e
Compare
|
Merged after discussion on slack. |
Fixes #16 and #17.
passage initbails out if~/.config/passageexists, unless--forceis passed.a-zA-Z_-.@0-9or some similarly restricted set.