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

return exitcode instead of bool #8

Merged
merged 7 commits into from
Jun 28, 2022
Merged

return exitcode instead of bool #8

merged 7 commits into from
Jun 28, 2022

Conversation

kaplanelad
Copy link
Member

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

@kaplanelad kaplanelad requested a review from jondot June 26, 2022 19:13
@kaplanelad kaplanelad self-assigned this Jun 26, 2022
log::info!("default cmd {:?}", matches.value_of("reporter"));
println!("going to run {}", bumblefoot::CMD);
bumblefoot::run();
Ok(true)
bumblefoot::CmdExit {
Copy link
Member

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.

Copy link
Member Author

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

bumblefoot/src/data.rs Outdated Show resolved Hide resolved
bumblefoot/Cargo.toml Outdated Show resolved Hide resolved

#[derive(Debug, Serialize, Deserialize)]
pub struct Definitions {
pub providers: HashMap<String, String>,
}

pub struct CmdExit {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@jondot jondot merged commit 11214c3 into master Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants