-
Notifications
You must be signed in to change notification settings - Fork 7
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
return exitcode instead of bool #8
Conversation
bumblefoot/src/bin/cmd/default.rs
Outdated
log::info!("default cmd {:?}", matches.value_of("reporter")); | ||
println!("going to run {}", bumblefoot::CMD); | ||
bumblefoot::run(); | ||
Ok(true) | ||
bumblefoot::CmdExit { |
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.
Maybe we try returning Result
? the reason I'm suggesting is because it would make it easier to write error producing code such as IO, network and more (e.g. opening files, etc.) and using ?
freely.
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.
yup, it sounds more flexible.
the CMD commands return Result<bumblefoot::CmdExit>
.
the exit logic is
If Ok,
take the CmdExit, print the text result if it exists, and exit with the given exit code
If Err
log the error and exit with the default const configuration
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct Definitions { | ||
pub providers: HashMap<String, String>, | ||
} | ||
|
||
pub struct CmdExit { |
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.
👌
Co-authored-by: Dotan J. Nahum <[email protected]>
Co-authored-by: Dotan J. Nahum <[email protected]>
following #6 issue, i have change the cmd return value from bool to exitcode
Also added the option to pass a custom message with different style depending on the exit code