first commit
This commit is contained in:
37
mdrsclient/__main__.py
Normal file
37
mdrsclient/__main__.py
Normal file
@ -0,0 +1,37 @@
|
||||
import argparse
|
||||
|
||||
from mdrsclient.commands import (
|
||||
ConfigCommand,
|
||||
FileCommand,
|
||||
FolderCommand,
|
||||
LaboratoryCommand,
|
||||
UserCommand,
|
||||
)
|
||||
from mdrsclient.exceptions import MDRSException
|
||||
|
||||
|
||||
def main() -> None:
|
||||
description = """This is a command-line program to up files."""
|
||||
|
||||
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
subparsers = parser.add_subparsers(title="subcommands")
|
||||
|
||||
ConfigCommand.register(subparsers)
|
||||
UserCommand.register(subparsers)
|
||||
LaboratoryCommand.register(subparsers)
|
||||
FolderCommand.register(subparsers)
|
||||
FileCommand.register(subparsers)
|
||||
|
||||
try:
|
||||
args = parser.parse_args()
|
||||
if hasattr(args, "func"):
|
||||
args.func(args)
|
||||
else:
|
||||
parser.print_help()
|
||||
except MDRSException as e:
|
||||
print(f"Error: {e}")
|
||||
exit(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user