mdrs-client-python/mdrsclient/__main__.py
2023-05-01 20:00:32 +09:00

38 lines
928 B
Python

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()