Command-line tool for seamlessly managing and switching between multiple GitHub accounts on a single machine, ideal for developers with both personal and professional profiles.
Before using HubSwitch, ensure that your GitHub accounts' details are properly set up in the configuration file (sampleConfig.json
). The configuration should include the GitHub username, email, and Personal Access Token (PAT) for each account. Ensure to store the path of the JSON file as an environment variable exactly named HubSwitch.
Note: store the config in a secure place as it contains sensitive information.
- Define the
HubSwitch
environment variable on your system, pointing to the location of your configuration file. - Edit
sampleConfig.json
to include your GitHub account details and rename file to preference.
Example sampleConfig.json
:
{
"version": 1.0,
"accounts": {
"work1": {
"account_name": "Work",
"username": "work_username",
"email": "[email protected]",
"PAT": "your_personal_access_token"
}
// ... Add other accounts as needed
},
"current": "work1" // Set the default activated account ID
}
- To run the
hubswitch
command through terminal, add the path of the repo folder to PATH environment variable (either User or System)
To activate an account, use the command activate followed by the account ID specified in your config file.
hubswitch activate work1
python main.py activate work1
To view the currently activated account, use the command current
hubswitch current
python main.py current
To list all accounts available in your configuration file, use the command accounts.
hubswitch accounts
python main.py accounts
To view the expected schema of your configuration file, use the command schema.
hubswitch schema
python main.py schema
To build the CLI tool, this project leverages the following python modules:
- Win32Cred: To access windows credentials.
- Typer: For creating the command-line interface.
- Rich: For enhanced printing in the console, including JSON.
- jsonschema: To validate JSON data against a predefined schema.