-
Notifications
You must be signed in to change notification settings - Fork 8
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
chore: make batch interactive #19
base: main
Are you sure you want to change the base?
Conversation
47c3f07
to
d6398cd
Compare
println!("do you want to confirm? y/n"); | ||
|
||
let mut input = String::new(); | ||
|
||
io::stdin() | ||
.read_line(&mut input) | ||
.expect("error: unable to read user input"); | ||
|
||
if !(input.trim() == "y" || input.trim() == "yes") { | ||
bail!("didn't confirm batch payment. exiting") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I've never written any rust that had interaction like this so I don't know if there is a library or a standard convention on how to do this. Would have to go looking at other code to know if there is a better way.
Without doing any research I'd say this looks fine.
You could avoid the double call to trim
but afaict it doesn't allocate so is negligible for this use-case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at https://lib.rs/command-line-interface, maybe dialoguer could be used https://github.com/mitsuhiko/dialoguer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eshanvaid this could be a good PR to take inspiration from about how to bring about batch payment. |
64ab5f2
to
330afe0
Compare
No description provided.