-
Notifications
You must be signed in to change notification settings - Fork 9
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
Revise exit status section #30
Open
codesections
wants to merge
8
commits into
rust-cli:master
Choose a base branch
from
codesections-forks:exit-status
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0c639db
Revise exit status section
codesections 9e9598c
Merge branch 'master' into exit-status
codesections a09fcd7
Minor changes for readability
codesections 68c2578
Refactor to avoid sentential value
codesections d97d93a
Change `match` statement to `if let` statement
codesections 71444fc
Add an iter method to the ExitStatuses enum
codesections 272a413
Clippy lints
codesections 4be6860
Revert removal of Option wrapping `code`
codesections File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ fn main() { | |
.paragraph("text for the custom section") | ||
.paragraph("Additional text for the custom section"), | ||
) | ||
.exit_status(ExitStatus::default()) | ||
.author(Author::new("Alice Person").email("[email protected]")) | ||
.author(Author::new("Bob Human").email("[email protected]")) | ||
.render(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// Add a exit status section | ||
#[derive(Debug, Clone, Default)] | ||
pub struct ExitStatus { | ||
pub(crate) code: Option<i32>, | ||
pub(crate) description: Option<&'static str>, | ||
pub(crate) use_default_instead: bool, | ||
} | ||
|
||
impl ExitStatus { | ||
pub fn new(code: i32) -> Self { | ||
Self { | ||
code: Some(code), | ||
description: None, | ||
use_default_instead: false, | ||
} | ||
} | ||
|
||
pub fn default() -> Self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are already deriving Default which generates an equivalent method |
||
Self { | ||
code: None, | ||
description: None, | ||
use_default_instead: true, | ||
} | ||
} | ||
|
||
pub fn description(mut self, description: &'static str) -> Self { | ||
self.description = Some(description); | ||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm confused. If you have a bunch of these and any one of them has this boolean flag set to true, you'll ignore all information and instead print a list of default statuses? I'd do this with an enum like
enum ExitStatuses { DefaultStatuses, List(Vec<ExitStatus>) }
(with ExitStatus containing fields for code and description)