2023-05-01 20:00:32 +09:00
|
|
|
import argparse
|
2023-05-11 18:55:48 +09:00
|
|
|
import sys
|
2023-05-01 20:00:32 +09:00
|
|
|
|
|
|
|
from mdrsclient.commands import (
|
2023-05-11 17:00:14 +09:00
|
|
|
ChaclCommand,
|
2023-05-01 20:00:32 +09:00
|
|
|
ConfigCommand,
|
2023-07-20 11:43:07 +09:00
|
|
|
CpCommand,
|
2023-05-10 18:17:35 +09:00
|
|
|
DownloadCommand,
|
|
|
|
FileMetadataCommand,
|
|
|
|
LabsCommand,
|
|
|
|
LoginCommand,
|
|
|
|
LogoutCommand,
|
|
|
|
LsCommand,
|
|
|
|
MetadataCommand,
|
|
|
|
MkdirCommand,
|
|
|
|
MvCommand,
|
|
|
|
RmCommand,
|
|
|
|
UploadCommand,
|
|
|
|
WhoamiCommand,
|
2023-05-01 20:00:32 +09:00
|
|
|
)
|
|
|
|
from mdrsclient.exceptions import MDRSException
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
2023-05-17 14:51:19 +09:00
|
|
|
description = """This is a command-line program for up- and downloading files to and from MDRS based repository."""
|
2023-05-01 20:00:32 +09:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter)
|
2023-05-10 18:17:35 +09:00
|
|
|
parsers = parser.add_subparsers(title="subcommands")
|
|
|
|
|
|
|
|
ConfigCommand.register(parsers)
|
|
|
|
LoginCommand.register(parsers)
|
|
|
|
LogoutCommand.register(parsers)
|
|
|
|
WhoamiCommand.register(parsers)
|
|
|
|
LabsCommand.register(parsers)
|
|
|
|
LsCommand.register(parsers)
|
|
|
|
MkdirCommand.register(parsers)
|
|
|
|
UploadCommand.register(parsers)
|
|
|
|
DownloadCommand.register(parsers)
|
|
|
|
MvCommand.register(parsers)
|
2023-07-20 11:43:07 +09:00
|
|
|
CpCommand.register(parsers)
|
2023-05-10 18:17:35 +09:00
|
|
|
RmCommand.register(parsers)
|
2023-05-11 17:00:14 +09:00
|
|
|
ChaclCommand.register(parsers)
|
2023-05-10 18:17:35 +09:00
|
|
|
MetadataCommand.register(parsers)
|
|
|
|
FileMetadataCommand.register(parsers)
|
2023-05-01 20:00:32 +09:00
|
|
|
|
|
|
|
try:
|
|
|
|
args = parser.parse_args()
|
|
|
|
if hasattr(args, "func"):
|
|
|
|
args.func(args)
|
|
|
|
else:
|
|
|
|
parser.print_help()
|
|
|
|
except MDRSException as e:
|
|
|
|
print(f"Error: {e}")
|
2023-05-11 18:55:48 +09:00
|
|
|
sys.exit(2)
|
2023-05-23 11:48:09 +09:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
sys.exit(130)
|
2023-05-01 20:00:32 +09:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|