extract-repo-url

Small CLI tool to extract repository URL from text (from clipboard by default)

MIT License

Downloads
1.8K
Stars
6
Committers
1

extract-repo-url

Installation

cargo install extract-repo-url

Basic Usage

Outputs a repository URL extracted from clipboard text.

$ extract-repo-url # From clipboard by default
https://github.com/foo/bar

$ extract-repo-url 'Repository https://github.com/foo/bar is awesome' # Can receive text as 1st param
https://github.com/foo/bar

It can also detect

  • Clone URL (e.g. [email protected]:foo/bar.git -> https://github.com/foo/bar)
  • File page on github (e.g. https://foo.github.io/bar/tree/master/tests/data -> https://github.com/foo/bar)
  • GitHub pages (e.g. https://foo.github.io/bar/ -> https://github.com/foo/bar)
  • Bitbucket (e.g. foo bar https://bitbucket.org/foo/bar -> https://bitbucket.org/foo/bar)
  • GitLab (e.g. foo bar https://gitlab.com/foo/bar -> https://gitlab.com/foo/bar)

You can add more hosts with $EXTRACT_REPO_URL_SERVICE_HOSTS environment variable.

export EXTRACT_REPO_URL_SERVICE_HOSTS="github.your-site.com, gitlab.your-site.com"

Please try --help option to see more details.

Use-cases

With Git:

$ git clone `extract-repo-url`

With open command (on macOS):

$ open `extract-repo-url`

Development

On Linux, you need to install X11 library:

sudo apt-get install xorg-dev

How to run test:

$ RUST_TEST_THREADS=1 cargo test

License

MIT