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

✨ Stop if there is no tags in repo and release option is absent #15

Merged
merged 6 commits into from
Feb 25, 2019

Conversation

charlyx
Copy link
Collaborator

@charlyx charlyx commented Feb 24, 2019

Hello @fabienjuif πŸ‘‹

This is my very first Rust contribution! πŸŽ‰

After reading your code I think I've added the message at the right position. Please tell me if I'm wrong!

At first I was going to use panic! as I want to display a message and stop the program but the result is not human-friendly.
I could have used human_panic but I didn't want to introduce a new dependency without talking to you first.

So here I am with a simple solution.

Happy to discuss! πŸ˜„

Fix #14

@fabienjuif
Copy link
Owner

Nice :)

I read that tomorrow, if I forgot just ping me!

About the new dependencies, I think this is not a panic message since your message is here to help human using the CLI.
So I think you did the right choice!

@fabienjuif
Copy link
Owner

If we wan't the error to be printed as a CLI, we should add it in main.rs, line 38 maybe, juste before changelog.to_markdown(

But if we wan't the error to be printed as a lib, the message is fine where you put it.
Except that a process.exit() in a lib is not fine :)
We should either:

  1. Let the message in CLI only (see first paragraph)
  2. Returns a Result<String, Err> in the to_markdown method

@fabienjuif
Copy link
Owner

fabienjuif commented Feb 25, 2019

What do you think?, I think the 1. is good enough

@charlyx
Copy link
Collaborator Author

charlyx commented Feb 25, 2019 via email

@fabienjuif
Copy link
Owner

Yes!
Thats it, you can use pattern matching in the main.rs if you want.

https://doc.rust-lang.org/std/result/enum.Result.html

@charlyx charlyx changed the title ✨ Stop if there is no tags in repo and release option is absent πŸŽ‰ Stop if there is no tags in repo and release option is absent Feb 25, 2019
src/changelog.rs Outdated Show resolved Hide resolved
Cargo.lock Show resolved Hide resolved
@@ -89,11 +91,17 @@ impl Changelog {
Changelog { versions }
}

pub fn to_markdown(&self, release: Option<&str>, print_authors: bool) -> String {
pub fn to_markdown(&self, release: Option<&str>, print_authors: bool) -> Result<String, Error> {
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a way to expose the std::Error instead of our custom one?

@charlyx charlyx changed the title πŸŽ‰ Stop if there is no tags in repo and release option is absent ✨ Stop if there is no tags in repo and release option is absent Feb 25, 2019
@fabienjuif fabienjuif merged commit 62c0b88 into fabienjuif:master Feb 25, 2019
@fabienjuif
Copy link
Owner

Thank you master, I publish it right now in 0.4.0

@charlyx charlyx deleted the 14-no-tag-message branch February 25, 2019 12:56
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.

None yet

2 participants