gh sizer
is an extension for the GitHub CLI which makes it easy to size one or more GitHub repos with git-sizer
without having to clone the repo(s) manually.
To use gh sizer
, you must already have the following dependencies available in your $PATH
:
- the GitHub CLI,
gh
, installed using the instructions here git-sizer
Before using gh sizer
, you should log in to the GitHub CLI by running gh auth login
.
gh sizer
is distributed as an extension for the GitHub CLI. Once you've installed the GitHub CLI and logged in, you can install the extension with a single command:
gh extension install timrogers/gh-sizer
To size a single repo, use the gh sizer repo
command:
gh sizer repo timrogers/gh-sizer
The repo will be automatically cloned and sized, and the output from git-sizer
will be printed to STDOUT. Afterwards, the cloned repo will be automatically deleted.
By default, the git-sizer
output will be in human-readable text format. For a machine-readable JSON output, specify the --output-format json
option:
gh sizer repo timrogers/gh-sizer --output-format json
The gh sizer generate-script
command allows you to generate a Bash or PowerShell script to size all repos belonging to a specific user or organization.
By default, the generate-script
command generates a Bash script.
Just run the following command, replacing gh-sizer-sandbox
with the user or organization whose repos you want to size:
gh sizer generate-script gh-sizer-sandbox
The command will print a Bash script to STDOUT which will size all of the repos belonging to gh-sizer-sandbox
and store the results in the output/
directory, with one file per repo named ${repository}.txt
.
You can store the generated script by piping the output to a file. To execute the script, just make that file executable and then run it:
gh sizer generate-script gh-sizer-sandbox > script.sh
chmod +x script.sh
./script.sh
You can ask the generate-script
command to generate a PowerShell script with the --script-type powershell
argument.
Just run the following command, replacing gh-sizer-sandbox
with the user or organization whose repos you want to size:
gh sizer generate-script gh-sizer-sandbox --script-type powershell
The command will print a PowerShell script to STDOUT which will size all of the repos belonging to gh-sizer-sandbox
and store the results in the output/
directory, with one file per repo named ${repository}.txt
.
You can store the generated script by piping the output to a file, and then execute it.
gh sizer generate-script gh-sizer-sandbox >> script.ps1
.\script.ps1
By default, gh-sizer
will run output one .txt
file for each repo to output/${repository.txt}
.
For machine-readable JSON output, specify the --output-format json
option:
gh sizer generate-script gh-sizer-sandbox --output-format json
You can customise the directory where the script saves its output and the filenames used with the --output-directory
and --output-filename
arguments. In the --output-filename
argument, you can use ${owner}
and ${repository}
as placeholders for the owner and repository name:
gh sizer generate-script gh-sizer-sandbox --output-directory results --output-filename "${owner}-${repository}.txt"