Parse --repo owner/name input in analyze command#8
Conversation
| } | ||
|
|
||
| fn main() { | ||
| fn main() -> Result<()> { |
There was a problem hiding this comment.
I don't like importing result from anyhow, let's specify anyhow::Result every time 😅
There was a problem hiding this comment.
Done. Dropped Result from the import and spelled out anyhow::Result in the signature.
| } | ||
| let (org, repo) = (parts[0], parts[1]); | ||
| println!("parsed org={org} repo={repo}"); | ||
| } |
There was a problem hiding this comment.
the main function should be small, let's have an analyze function in an analyze.rs file under a command directory.
Then have another function that parses a string and returns a struct with org and repo
Then you can add a test that tests that this function works
There was a problem hiding this comment.
I have Moved the analyze logic into src/command/analyze.rs, added a ParsedRepo struct with parse_repo, and added tests for the happy path and four failure cases.
| use anyhow::bail; | ||
|
|
||
| #[derive(Debug, PartialEq)] | ||
| pub struct ParsedRepo { |
There was a problem hiding this comment.
I think Repo is enough but can be changed in another PR
|
please squash your commits next time if the PR is ready to be merged 🙏 |
Noted . I will definately put that in mind next time |
This is the first small piece of the analyze command .When
--repois passed toanalyze, the value is split on/and rejected unless it has exactly two non-empty parts. For now it just prints the parsed owner and repo as a sanity check,Also added
anyhowsomaincan returnResult<()>and usebail!for the error message.