10
310
Fork
You've already forked codeberg-cli
33

feat: add --repo flag to all repository-dependent commands #248

Merged
Aviac merged 4 commits from timstoop/codeberg-cli:feat-add-repo-flag-to-issue-pull-commands into main 2025年10月08日 18:59:16 +02:00
Contributor
Copy link

Add --repo flag to allow specifying repository without being in a git
directory. This flag accepts OWNER/REPO format and enables working with
repositories from anywhere.

Commands updated:

Issue commands:

  • issue view
  • issue create
  • issue edit
  • issue comment

Pull request commands:

  • pull view
  • pull create
  • pull edit
  • pull comment

Milestone commands:

  • milestone view
  • milestone create
  • milestone edit
  • milestone list

Label commands:

  • label create
  • label edit
  • label list
  • label delete

Release commands:

  • release list
  • release create

Repository commands:

  • repo assignees

All commands now support the --repo OWNER/REPO flag to specify the target
repository, allowing users to work across multiple repositories without
changing directories.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Add --repo flag to allow specifying repository without being in a git directory. This flag accepts OWNER/REPO format and enables working with repositories from anywhere. Commands updated: Issue commands: - issue view - issue create - issue edit - issue comment Pull request commands: - pull view - pull create - pull edit - pull comment Milestone commands: - milestone view - milestone create - milestone edit - milestone list Label commands: - label create - label edit - label list - label delete Release commands: - release list - release create Repository commands: - repo assignees All commands now support the --repo OWNER/REPO flag to specify the target repository, allowing users to work across multiple repositories without changing directories. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Aviac requested changes 2025年10月07日 09:04:39 +02:00
Dismissed
Aviac left a comment
Owner
Copy link

Ufff, at this point I would really love to see the RepoOwner arg of all the subcommands to be refactored into a separate struct which can be passed. Something along the lines of:

struct RepoOwner{repo: String,owner: String
}struct SomeSubcommandArgs{#[arg(...)]pubrepo_owner: Option<RepoOwner>}

Then you could also implement the parsing via clap and make it fail at parse time of the CLI command. This way we avoid the repetition of this

letOwnerRepo{owner,repo}=ifletSome(repo_str)=&ctx.args.repo{let(owner,repo)=parse_owner_and_repo(repo_str)?;OwnerRepo{owner,repo}}else{ctx.owner_repo()?};
Ufff, at this point I would really love to see the `RepoOwner` arg of all the subcommands to be refactored into a separate struct which can be passed. Something along the lines of: ```rs struct RepoOwner { repo: String, owner: String } struct SomeSubcommandArgs { #[arg(...)] pub repo_owner: Option<RepoOwner> } ``` Then you could also implement the parsing via clap and make it fail at parse time of the CLI command. This way we avoid the repetition of this ```rs let OwnerRepo { owner, repo } = if let Some(repo_str) = &ctx.args.repo { let (owner, repo) = parse_owner_and_repo(repo_str)?; OwnerRepo { owner, repo } } else { ctx.owner_repo()? }; ```
Author
Contributor
Copy link

I can do that. Shall I make that so across the entire codebase, not just with these?

I can do that. Shall I make that so across the entire codebase, not just with these?
Author
Contributor
Copy link

Like this?

Edit: No, I don't like it, new commit incoming.

Like this? Edit: No, I don't like it, new commit incoming.
timstoop force-pushed feat-add-repo-flag-to-issue-pull-commands from 7c8c24401a to 6cd0617da6 2025年10月07日 10:42:57 +02:00 Compare
Author
Contributor
Copy link

I think this is cleaner and more concise. What do you prefer?

I think this is cleaner and more concise. What do you prefer?
timstoop force-pushed feat-add-repo-flag-to-issue-pull-commands from 6cd0617da6 to 2773e2fb30 2025年10月07日 10:46:16 +02:00 Compare
Aviac requested changes 2025年10月07日 16:38:47 +02:00
Dismissed
Aviac left a comment
Owner
Copy link

I agree that it looks much nicer and simpler. Thank you for working on this!

I have another small nit however and would really like to see this changed to keep the code clean.

I agree that it looks much nicer and simpler. Thank you for working on this! I have another small nit however and would really like to see this changed to keep the code clean.
src/types/git.rs Outdated
@ -8,3 +10,4 @@
pubrepo: String,
}
implFrom<&RepoOwner>forOwnerRepo{
Owner
Copy link

Ahhh my bad, we already have OwnerRepo. I forgot about that. Maybe we can consolidate RepoOwner into this struct? Otherwise we would have two similar things for the same purpose. This also saves us another conversion and a few lines of code. Sorry that I didn't find this earlier myself!

Ahhh my bad, we already have `OwnerRepo`. I forgot about that. Maybe we can consolidate `RepoOwner` into this struct? Otherwise we would have two similar things for the same purpose. This also saves us another conversion and a few lines of code. Sorry that I didn't find this earlier myself!
Author
Contributor
Copy link

Like what I just pushed?

Like what I just pushed?
Merged the RepoOwner struct into the existing OwnerRepo struct to avoid
duplication, as suggested in PR review. Changes include:
- Moved FromStr implementation from RepoOwner to OwnerRepo
- Moved all tests to OwnerRepo in src/types/git.rs
- Updated all commands to use OwnerRepo with clap parsing
- Removed RepoOwner struct from parsing.rs
- Simplified conversion logic by using .clone() instead of From trait
- Added tests for parse_owner_and_repo function
This eliminates the need for From<&RepoOwner> conversion and reduces
code duplication while maintaining all functionality.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Aviac left a comment
Owner
Copy link

There are still things that can use some polishing, but I'll just merge asap and clean it up myself afterwards so that this PR doesn't become a needless torment for you. Thanks for the contribution! 🌟

There are still things that can use some polishing, but I'll just merge asap and clean it up myself afterwards so that this PR doesn't become a needless torment for you. Thanks for the contribution! 🌟
Author
Contributor
Copy link

I appreciate it, but I also don't mind doing the polishing. Tbf, I'm kind of using this (and the "pair programming with AI") to teach myself some better Rust, so feel free to give me chores. If it's repetitive, I just employ my... assistant ;-)

I appreciate it, but I also don't mind doing the polishing. Tbf, I'm kind of using this (and the "pair programming with AI") to teach myself some better Rust, so feel free to give me chores. If it's repetitive, I just employ my... assistant ;-)
Owner
Copy link

Well, let me at least tell you what I want to do:

  • One of the files is obsolete (the parsing.rs)
  • rustfmt wasn't run according to the repos rules
Well, let me at least tell you what I want to do: - One of the files is obsolete (the `parsing.rs`) - `rustfmt` wasn't run according to the repos rules
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Aviac/codeberg-cli!248
Reference in a new issue
Aviac/codeberg-cli
No description provided.
Delete branch "timstoop/codeberg-cli:feat-add-repo-flag-to-issue-pull-commands"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?