cli: make devscripts subcommand more accessible #18

Merged
oysteikt merged 1 commits from make-devscripts-more-accessible into main 2024-07-28 14:33:11 +02:00
3 changed files with 19 additions and 9 deletions
Showing only changes of commit 8161e5e92a - Show all commits

View File

@ -7,6 +7,7 @@ from sqlalchemy.orm import Session
from .services import ( from .services import (
Config, Config,
arg_parser, arg_parser,
devscripts_arg_parser,
) )
from .deadline_daemon import DeadlineDaemon from .deadline_daemon import DeadlineDaemon
@ -69,7 +70,7 @@ def main():
from .devscripts.seed_test_data import main from .devscripts.seed_test_data import main
main(sql_session) main(sql_session)
else: else:
print(f'Error: no such script: {args.script}') print(devscripts_arg_parser.format_help())
exit(1) exit(1)
exit(0) exit(0)
@ -84,3 +85,4 @@ def main():
exit(0) exit(0)
print(arg_parser.format_help()) print(arg_parser.format_help())
exit(1)

View File

@ -1,4 +1,7 @@
from .argument_parser import arg_parser from .argument_parser import (
arg_parser,
devscripts_arg_parser,
)
from .bookcase_item import ( from .bookcase_item import (
create_bookcase_item_from_isbn, create_bookcase_item_from_isbn,
is_valid_isbn, is_valid_isbn,

View File

@ -31,12 +31,17 @@ subparsers.add_parser(
help = 'Start the web interface in production mode', help = 'Start the web interface in production mode',
) )
subparsers.add_parser( devscripts_arg_parser = subparsers.add_parser('devscripts', help='Run development scripts')
'devscripts', devscripts_subparsers = devscripts_arg_parser.add_subparsers(dest='script')
help = 'Run development scripts',
).add_argument( devscripts_subparsers.add_parser(
'script', 'seed-test-data',
help = 'The development script to run', help = 'Seed test data in the database',
)
devscripts_subparsers.add_parser(
'seed-content-for-deadline-daemon',
help = 'Seed data tailorded for testing the deadline daemon, into the database',
) )
arg_parser.add_argument( arg_parser.add_argument(