diff --git a/scripts/create_repo b/scripts/create_repo index 32a5c4e..12bc7e7 100644 --- a/scripts/create_repo +++ b/scripts/create_repo @@ -1,2 +1 @@ -#!/bin/bash -python create_repo.py "$@" +python create_repo.py [-d DESCRIPTION] diff --git a/scripts/create_repo.py b/scripts/create_repo.py index 9bb5eda..a942bbd 100644 --- a/scripts/create_repo.py +++ b/scripts/create_repo.py @@ -11,8 +11,7 @@ URL = "https://api.github.com/user/repos" -parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository') # noqa: E501 - +parser = argparse.ArgumentParser(description='creates a local repository linked with a remote repository') parser.add_argument('path', metavar='PATH', type=str, @@ -21,8 +20,14 @@ metavar='NAME', type=str, help='Enter a name for the new repository') +parser.add_argument('-d', + '--description', + metavar='DESCRIPTION', + type=str, + help='Enter a description for the new repository') args = parser.parse_args() + name = args.name path = args.path @@ -36,13 +41,14 @@ conn = http.client.HTTPSConnection("api.github.com") payload = json.dumps({ - "name": name, - "description": "made with the GitHub API" + "name": name, + "description": args.description # Modify the value here }) + headers = { - 'Authorization': f'Bearer {GITHUB_API_TOKEN}', - 'Content-Type': 'application/json', - 'User-Agent': f'{USERNAME}' + 'Authorization': f'Bearer {GITHUB_API_TOKEN}', + 'Content-Type': 'application/json', + 'User-Agent': f'{USERNAME}' } conn.request("POST", "/user/repos", payload, headers)