diff --git a/src/vstarstack/tool/clean.py b/src/vstarstack/tool/clean.py index c2b97c36..e219e653 100644 --- a/src/vstarstack/tool/clean.py +++ b/src/vstarstack/tool/clean.py @@ -15,7 +15,6 @@ import os import vstarstack.tool.common -import vstarstack.library.common import vstarstack.tool.cfg def run(project: vstarstack.tool.cfg.Project, _argv: list): diff --git a/src/vstarstack/tool/debayer.py b/src/vstarstack/tool/debayer.py index 3c188609..35c3aa4d 100644 --- a/src/vstarstack/tool/debayer.py +++ b/src/vstarstack/tool/debayer.py @@ -74,5 +74,6 @@ def _process(project: vstarstack.tool.cfg.Project, argv: list): project.config.paths.npy_orig, project.config.paths.npy_fixed) -def run(project: vstarstack.tool.cfg.Project, argv: list): - _process(project, argv) +commands = { + "*": (_process, "debayer image", "input/ output/"), +} diff --git a/src/vstarstack/tool/process.py b/src/vstarstack/tool/process.py index 49fe76f1..d506168f 100644 --- a/src/vstarstack/tool/process.py +++ b/src/vstarstack/tool/process.py @@ -17,51 +17,38 @@ import vstarstack.tool.usage import vstarstack.tool.manage_project -import vstarstack.tool.config -import vstarstack.tool.image import vstarstack.tool.clean -import vstarstack.tool.readimage -import vstarstack.tool.merge -import vstarstack.tool.debayer -import vstarstack.tool.stars.stars -import vstarstack.tool.cluster -import vstarstack.tool.shift -import vstarstack.tool.image_processing.fixes -import vstarstack.tool.fine_shift.fine_shift -import vstarstack.tool.objects.objects -import vstarstack.tool.calibration -import vstarstack.tool.analyzers.analyzers commands = { - "readimage": (vstarstack.tool.readimage.commands, + "readimage": ("vstarstack.tool.readimage", "read source images to npz"), - "debayer": (vstarstack.tool.debayer.run, + "debayer": ("vstarstack.tool.debayer", "debayer RAW images"), - "image-process": (vstarstack.tool.image_processing.fixes.commands, + "image-process": ("vstarstack.tool.image_processing.fixes", "image-process - make optical fixes and other image fixes"), - "calibration": (vstarstack.tool.calibration.commands, + "calibration": ("vstarstack.tool.calibration", "calibration - flats, darks"), - "objects": (vstarstack.tool.objects.objects.commands, + "objects": ("vstarstack.tool.objects.objects", "commands for processing images with compact objects " + "(planets, diffractions, etc)"), - "stars": (vstarstack.tool.stars.stars.commands, + "stars": ("vstarstack.tool.stars.stars", "commands for processing stars images"), - "cluster": (vstarstack.tool.cluster.commands, + "cluster": ("vstarstack.tool.cluster", "command for cluster processing"), - "shift": (vstarstack.tool.shift.commands, + "shift": ("vstarstack.tool.shift", "move and rotate images to match them"), - "merge": (vstarstack.tool.merge.commands, + "merge": ("vstarstack.tool.merge", "merge images", "input_dir/ output.npz"), "project": (vstarstack.tool.manage_project.run, "configurate project"), # "planets": (vstarstack.targets.planets.planets.run, # "commands for processing planets"), - "image": (vstarstack.tool.image.commands, + "image": ("vstarstack.tool.image", "image processing (show, convert, etc)"), "clean": (vstarstack.tool.clean.run, "remove temporary files"), - "fine-shift": (vstarstack.tool.fine_shift.fine_shift.commands, + "fine-shift": ("vstarstack.tool.fine_shift.fine_shift", "fine shift images"), - "analyzers": (vstarstack.tool.analyzers.analyzers.commands, + "analyzers": ("vstarstack.tool.analyzers.analyzers", "analyze images"), } diff --git a/src/vstarstack/tool/usage.py b/src/vstarstack/tool/usage.py index 1433bc86..44e24862 100644 --- a/src/vstarstack/tool/usage.py +++ b/src/vstarstack/tool/usage.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 Vladislav Tsendrovskii +# Copyright (c) 2022-2024 Vladislav Tsendrovskii # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,6 +13,8 @@ # import os +import importlib + _PRGNAME = "vstarstack" def complete_path_in_dir(dirname : str | None, prefix : str): @@ -80,6 +82,10 @@ def autocompletion(commands : dict, argv : list): if isinstance(command, dict): """Go to subcommand completion""" return autocompletion(command, argv[1:]) + elif isinstance(command, str): + """Go to subcommand completion""" + loaded_submodule = importlib.import_module(command) + return autocompletion(loaded_submodule.commands, argv[1:]) else: return autocomplete_files(argv[1:]) @@ -135,5 +141,12 @@ def run(project, argv, base, commands, message=None): else: new_base = cmd run(project, argv[1:], new_base, submodule, message) + elif isinstance(submodule, str): + if len(base) > 0: + new_base = base + " " + cmd + else: + new_base = cmd + loaded_submodule = importlib.import_module(submodule) + run(project, argv[1:], new_base, loaded_submodule.commands, message) else: submodule(project, argv[1:])