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
HubSwitchenvironment variable on your system, pointing to the location of your configuration file. - Edit
sampleConfig.jsonto 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": "work_email@example.com",
"PAT": "your_personal_access_token"
}
// ... Add other accounts as needed
},
"current": "work1" // Set the default activated account ID
}
- To run the
hubswitchcommand 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 work1python main.py activate work1To view the currently activated account, use the command current
hubswitch currentpython main.py currentTo list all accounts available in your configuration file, use the command accounts.
hubswitch accountspython main.py accountsTo view the expected schema of your configuration file, use the command schema.
hubswitch schemapython main.py schemaTo 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.
