https://github.com/kislerdm/github-downloader
CLI to download part of codebase from bulky mono-repo
https://github.com/kislerdm/github-downloader
cli github github-api golang
Last synced: 11 months ago
JSON representation
CLI to download part of codebase from bulky mono-repo
- Host: GitHub
- URL: https://github.com/kislerdm/github-downloader
- Owner: kislerdm
- License: mit
- Created: 2021-06-30T00:14:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-09T23:58:51.000Z (over 3 years ago)
- Last Synced: 2025-02-23T01:11:28.175Z (11 months ago)
- Topics: cli, github, github-api, golang
- Language: Go
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub Simple Downloader
**Motivation**: It is often required to fetch a couple of codebase modules from bulky monorepo. Unfortunately standard [git client](https://git-scm.com/) doesn't permit for such operation directly. Github provides a set of API endpoints to achieve that objective though.
*The repo contains the codebase of the CLI tool* to download part of the codebase: either a file/blob, or directory/tree from a github repository.
## Installation
### Requirements
- [cURL](https://curl.se/)
- [tar](https://man7.org/linux/man-pages/man1/tar.1.html)
### Instructions
Run to install:
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/kislerdm/github-downloader/HEAD/install.sh)"
```
## How to use
**Note** The tool was not tested in windows.
- Run to see the help:
```bash
github-downloader -h
```
- Run to fetch the current version of the app:
```bash
github-downloader -b https://github.com/kislerdm/github-downloader/blob/master/cli/VERSION
```
You shall see the following in stdout:
```bash
2021/06/30 17:42:11 Download [4 bytes] cli/VERSION
```
Now if you were to run the command:
```bash
cat /tmp/cli/VERSION
```
You shall expect to see the current version of the app.
## How to use github token
It is advised to authenticate with github to overcome the API calls [rate limit](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). Please follow [the instructions](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) to setup an access token.
The required authorization scope is `repo`.
There are two options to allow the CLI to access the token:
- Export the token as an environmental variable `GITHUB_TOKEN`
- Provide the token as a cmd option:
```bash
github-downloader -token=xxxxxx https://github.com/kislerdm/github-downloader/blob/master/cli/VERSION
```
### Note
The *cmd option token* is prioritized above the environmental variable. In the other words, if you export token as an envvar and provide another token as the cmd option `token`, the later value will be used to authenticate with the github API.
## Collaboration
If you find this tool useful but missing some features, please open a github issue, or submit a PR with modifications.
### Note
The codebase is distributed under [the MIT copyright license](./LICENSE).
## Author
[Dmitry Kisler](https://www.dkisler.com)
Feel free to get in touch [here](https://www.linkedin.com/in/dkisler/) to chat over tech stuff :)