Here’s the updated README.md file with the inclusion of the requirements.txt and instructions for setting it up:
This is a command-line tool that allows you to interact with the GitHub API. It provides functionality to retrieve user information, list repositories, search for repositories by keyword, and fetch commit details for a specific repository.
- Retrieve detailed information about a GitHub user.
- List all public repositories for a given user.
- Search for repositories based on a keyword.
- Fetch commit history for a specific repository and branch.
Before using this tool, ensure you have the following installed:
- Python 3.6 or higher
pip(Python package manager)
-
Clone the repository:
git clone https://github.com/your-repo-url.git cd github-cli-tool -
Install the required dependencies using the
requirements.txtfile:pip install -r requirements.txt
This will install the following packages:
requests==2.32.3python-dotenv==1.0.1
-
Create a
.envfile in the root directory and add your GitHub API token:GIT_API_TOKEN=your_github_api_token_here
You can generate a personal access token from your GitHub account settings under "Developer Settings" -> "Personal Access Tokens".
Run the tool from the command line:
python github_cli.py [command] [arguments]For help:
python github_cli.py --helpRetrieve details about a GitHub user.
Command:
python github_cli.py user <username>Example:
python github_cli.py user octocatOutput:
Github user: octocat
Name: The Octocat
Bio: The Octocat is here to help!
Public Repos: 10
List all public repositories for a given user.
Command:
python github_cli.py repos <username>Example:
python github_cli.py repos octocatOutput:
Repositories of octocat:
- Hello-World (https://github.com/octocat/Hello-World)
- Spoon-Knife (https://github.com/octocat/Spoon-Knife)
Search for repositories owned by a user that match a specific keyword.
Command:
python github_cli.py search <username> <keyword>Example:
python github_cli.py search octocat helloOutput:
Repositories with keyword 'hello':
************
- Hello-World (https://github.com/octocat/Hello-World)
Fetch the commit history for a specific repository and branch.
Command:
python github_cli.py commits <username> <repo> [branch]Example:
python github_cli.py commits octocat Hello-World mainOutput:
Hello-World has '5' commits:
1- The Octocat : Initial commit
2- The Octocat : Add README
3- The Octocat : Update README
4- The Octocat : Fix typo
5- The Octocat : Add license
Note: The default branch is main. If the repository uses a different branch, specify it as the third argument.
The tool requires a GitHub API token to authenticate requests. Add the following variable to your .env file:
GIT_API_TOKEN=your_github_api_token_hereYou can obtain a personal access token from your GitHub account settings.
The project depends on the following Python libraries:
requests==2.32.3: For making HTTP requests to the GitHub API.python-dotenv==1.0.1: For loading environment variables from a.envfile.
These dependencies are listed in the requirements.txt file. To install them, run:
pip install -r requirements.txtContributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and submit a pull request.
Please ensure that your code adheres to the existing style and includes appropriate tests.
This project is licensed under the MIT License. See the LICENSE file for more details.
If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub Issues page.