1 unstable release
0.7.0 | Jan 2, 2025 |
---|
#1306 in Command line utilities
131 downloads per month
66KB
788 lines
GitHub | crates.io | Issues | Changelog
The ghrepo-cli
package provides a ghrepo
command for for getting the GitHub
repository associated with a local Git repository, optionally along with
various derived URLs for the repository like the REST v3 API URL.
Installation
In order to install the ghrepo
command, you first need to have Rust and
Cargo installed. You can then build
the latest release of ghrepo-cli
and install it in ~/.cargo/bin
by running:
cargo install ghrepo-cli
Usage
ghrepo [<options>] [<dirpath>]
ghrepo
retrieves the URL of the origin
remote (or another remote specified
with the --remote
option) of the Git repository located in <dirpath>
(or
the current directory if no argument is given) and parses it to determine what
GitHub repository it points to. By default, the command just outputs the
GitHub repository "fullname" (a string of the form {owner}/{name}
), but if
the -J
or --json
option is supplied, a JSON object is output instead,
containing fields for the repository owner, name, fullname, and individual
URLs, like so:
{
"owner": "jwodder",
"name": "ghrepo-rust",
"fullname": "jwodder/ghrepo-rust",
"api_url": "https://api.github.com/repos/jwodder/ghrepo-rust",
"clone_url": "https://github.com/jwodder/ghrepo-rust.git",
"git_url": "git://github.com/jwodder/ghrepo-rust.git",
"html_url": "https://github.com/jwodder/ghrepo-rust",
"ssh_url": "git@github.com:jwodder/ghrepo-rust.git"
}
Options
-J
,--json
— Output JSON-r REMOTE
,--remote REMOTE
— Parse the GitHub URL from the given remote [default:origin
]
Dependencies
~71KB