Exemplo n.º 1
0
def main(repository: str, description='', private=''):
    # Get username and password from environment
    username = config('USERNAME')
    password = config('PASSWORD')

    private = True if private else False

    # Get the absolute path to the folder -
    # the path where the script is executed via bash
    folder = check_output(['bash', '-c', 'pwd']).decode('utf-8').strip()

    # Try to connecting to GitHub and create a new repository
    # with a standard README.md file in it
    try:
        git = Git(username, password)
        git.create_repository(repository, description, private, init=True)
    except Exception as e:
        print(e)
        return

    print(f'\nRepository "{repository}" has been created.')

    print('\nInitializing repository:')

    # Get data from GitHub repository to local
    if not local_repository(username, repository, folder):
        print('\nUnable to initialize local repository!')
        return

    # Open the local repository in vs code
    if not open_in_vscode(path.join(folder, repository)):
        print('\nUnable to open folder with local repository!')
        return

    print('Done!')