github-data-cli: ghd

A small set of functionality to retrieve repository data from github, in JSON format.

Installation

No installation required, as you can execute ghd using the full file path from anywhere. For convenience symlink ghd to your PATH.

ln -s "$PWD/ghd" "$HOME/bin/ghd"

Usage

Make sure you have loaded relevant github credentials by setting the following environment variables. Get your own credentials by registering a new github oauth application. The values for application name, homepage url, application description, and authorization callback url do not matter for ghd; pick your own values.

  • GITHUB_CLIENT_ID
  • GITHUB_CLIENT_SECRET

Authenticate yourself. If enabled, you will be asked for a 2-factor authentication code.

ghd authenticate <username>

Now execute the main command.

ghd
Usage: ghd <action>
Source folder: .../github-data-cli
Actions available in the source folder:
  authenticate
  contributors
  diff-contributors
  diff-help
  diff-stargazers
  diff
  help
  repositories-help
  repositories-json
  repositories-list
  repositories
  star
  stargazers
  unstar

Notes

  • These scripts grew “organically”, starting from nothing. The first need was a function for shared credentials, then pagination, then caching, then then then. Don’t judge the code style too harshly, unless you have concrete suggestions in the form of a pull request ;)

Copyright © 2016, 2017, 2018 Joel Purra. Released under GNU General Public License version 3.0 (GPL-3.0).