Skip to content

Commit f12b877

Browse files
committed
Keep backwards compatability by going back to "--token" for classic.
Allow "file://" uri for "--token-fine".
1 parent 61275c6 commit f12b877

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

README.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ CLI Usage is as follows::
5858
-p PASSWORD, --password PASSWORD
5959
password for basic auth. If a username is given but
6060
not a password, the password will be prompted for.
61-
-f TOKEN_FINE, --token-fine TOKEN
62-
fine-grained personal access token
63-
-t TOKEN_CLASSIC, --token-classic TOKEN
61+
-f TOKEN_FINE, --token-fine TOKEN_FINE
62+
fine-grained personal access token or path to token
63+
(file://...)
64+
-t TOKEN_CLASSIC, --token TOKEN_CLASSIC
6465
personal access, OAuth, or JSON Web token, or path to
6566
token (file://...)
6667
--as-app authenticate as github app instead of as a user.

github_backup/github_backup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def parse_args(args=None):
150150
'If a username is given but not a password, the '
151151
'password will be prompted for.')
152152
parser.add_argument('-t',
153-
'--token-classic',
153+
'--token',
154154
dest='token_classic',
155155
help='personal access, OAuth, or JSON Web token, or path to token (file://...)') # noqa
156156
parser.add_argument('-f',
@@ -362,6 +362,11 @@ def get_auth(args, encode=True, for_git_cli=False):
362362
elif args.osx_keychain_item_account:
363363
raise Exception('You must specify both name and account fields for osx keychain password items')
364364
elif args.token_fine:
365+
_path_specifier = 'file://'
366+
if args.token_fine.startswith(_path_specifier):
367+
args.token_fine = open(args.token_fine[len(_path_specifier):],
368+
'rt').readline().strip()
369+
365370
if args.token_fine.startswith("github_pat_"):
366371
auth = args.token_fine
367372
else:
@@ -371,6 +376,7 @@ def get_auth(args, encode=True, for_git_cli=False):
371376
if args.token_classic.startswith(_path_specifier):
372377
args.token_classic = open(args.token_classic[len(_path_specifier):],
373378
'rt').readline().strip()
379+
374380
if not args.as_app:
375381
auth = args.token_classic + ':' + 'x-oauth-basic'
376382
else:

0 commit comments

Comments
 (0)