Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit b82e98b

Browse files
authored
Merge pull request #73 from cgwalters/config-while-you-config-yo
main: Support a -c/--config argument
2 parents 97f76f0 + b0c0626 commit b82e98b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

homu/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,8 @@ def arguments():
10661066
'continuous integration service')
10671067
parser.add_argument('-v', '--verbose',
10681068
action='store_true', help='Enable more verbose logging')
1069+
parser.add_argument('-c', '--config',
1070+
action='store', help='Path to cfg.toml', default='cfg.toml')
10691071

10701072
return parser.parse_args()
10711073

@@ -1078,11 +1080,15 @@ def main():
10781080
logger.addHandler(logging.StreamHandler())
10791081

10801082
try:
1081-
with open('cfg.toml') as fp:
1083+
with open(args.config) as fp:
10821084
cfg = toml.loads(fp.read())
10831085
except FileNotFoundError:
1084-
with open('cfg.json') as fp:
1085-
cfg = json.loads(fp.read())
1086+
# Fall back to cfg.json only if we're using the defaults
1087+
if args.config == 'cfg.toml':
1088+
with open('cfg.json') as fp:
1089+
cfg = json.loads(fp.read())
1090+
else:
1091+
raise
10861092

10871093
gh = github3.login(token=cfg['github']['access_token'])
10881094
user = gh.user()

0 commit comments

Comments
 (0)