ghget-cli
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

ghget

CI codecov

Download a directory or file from a GitHub URL you are viewing.

Requirements

The corresponding CLI must be installed and authenticated.

Why install CLI?

This tool uses GitHub or GitLab rest api to fetch repository archive. It is possible to authenticate with an access token, but an additional token must be issued, which must then be passed to the tool.

To keep it simple and robust, we are taking advantage of the CLI's authentication feature.

Install

You can quickly try with npx

npx ghget-cli@latest https://github.com/bisquit/ghget/tree/main/sample

or install globally

npm
npm i -g ghget-cli
yarn
yarn global add ghget-cli
pnpm
pnpm add -g ghget-cli

Usage

Hit ghget <url>.

ghget https://github.com/bisquit/ghget/tree/main/sample

See examples.

How it works

This tool fetches archive(.zip) with API, and after user confirmed, decompresses it and copies into current directory.

Because branches can include /, we cannot distinguish the URL main/src is which:

  • a) main/src branch
  • b) main branch and src directory

So it attempts to fetch archive with "possible refs" (in this case, main and main/src) concurrently.

It takes a bit networking cost, but works faster than git clone.

Related and Comparison

This tool is initialy inspired by

While these are primarily intended for scaffolding, this tool is designed for getting a portion of the repository.

Also I aimed for intuitive commands you don't need to remember how to specify.

Package Sidebar

Install

npm i ghget-cli

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

24.6 kB

Total Files

5

Last publish

Collaborators

  • bisquit