Skip to content

Commit

Permalink
use match statement instead of ifs
Browse files Browse the repository at this point in the history
  • Loading branch information
lunarserge committed Sep 24, 2024
1 parent 17eca92 commit d8eae0d
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/facere_sensum/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,18 @@ def main():
sys.exit(1)

log = config['log']
if args.command == 'create':
command_create(config, log)
elif args.command == 'update':
command_update(config, log, datetime.date.today())
print('\nSee you next time!')
elif args.command == 'chart':
command_chart(config)
else: # pragma: no cover
# Should never get here given that all the actions are processed above.
print('Something weird happened.',
'Please submit an issue at https://github.com/lunarserge/facere-sensum/issues/new',
'with the command that led here.')
sys.exit(1)
match args.command:
case 'create':
command_create(config, log)
case 'update':
command_update(config, log, datetime.date.today())
print('\nSee you next time!')
case 'chart':
command_chart(config)
case _: # pragma: no cover
# Should never get here given that all the actions are processed above.
print('Something weird happened.',
'Please submit an issue at',
'https://github.com/lunarserge/facere-sensum/issues/new',
'with the command that led here.')
sys.exit(1)

0 comments on commit d8eae0d

Please sign in to comment.