diff --git a/README.rst b/README.rst index 3b846ce..40fcee9 100644 --- a/README.rst +++ b/README.rst @@ -21,12 +21,12 @@ Usage CLI Usage is as follows:: Github Backup [-h] [-u USERNAME] [-p PASSWORD] [-t TOKEN] - [-o OUTPUT_DIRECTORY] [--starred] [--watched] [--all] - [--issues] [--issue-comments] [--issue-events] - [--repositories] [--wikis] [--skip-existing] - [-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX] - [-R REPOSITORY] [-P] [-F] [-v] - USER + [-o OUTPUT_DIRECTORY] [--starred] [--watched] [--all] + [--issues] [--issue-comments] [--issue-events] + [--repositories] [--wikis] [--skip-existing] + [-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX] [-O] + [-R REPOSITORY] [-P] [-F] [-v] + USER Backup a github users account @@ -56,6 +56,7 @@ CLI Usage is as follows:: only allow these languages -N NAME_REGEX, --name-regex NAME_REGEX python regex to match names against + -O, --organization whether or not this is a query for an organization -R REPOSITORY, --repository REPOSITORY name of repository to limit backup to -P, --private include private repositories diff --git a/bin/github-backup b/bin/github-backup index 7795f11..422a3f2 100644 --- a/bin/github-backup +++ b/bin/github-backup @@ -91,6 +91,7 @@ def parse_args(): parser.add_argument('--skip-existing', action='store_true', dest='skip_existing', help='skip project if a backup directory exists') parser.add_argument('-L', '--languages', dest='languages', help='only allow these languages', nargs='*') parser.add_argument('-N', '--name-regex', dest='name_regex', help='python regex to match names against') + parser.add_argument('-O', '--organization', action='store_true', dest='organization', help='whether or not this is a query for an organization') parser.add_argument('-R', '--repository', dest='repository', help='name of repository to limit backup to') parser.add_argument('-P', '--private', action='store_true', dest='private', help='include private repositories') parser.add_argument('-F', '--fork', action='store_true', dest='fork', help='include forked repositories') @@ -168,6 +169,8 @@ def retrieve_repositories(args): log_info('Retrieving repositories') single_request = False template = 'https://api.github.com/users/{0}/repos'.format(args.user) + if args.organization: + template = 'https://api.github.com/orgs/{0}/repos'.format(args.user) if args.repository: single_request = True