Add module cli

This commit is contained in:
2026-04-09 19:21:25 +02:00
parent 9e2fe5f2df
commit ff45f836b3
+37
View File
@@ -0,0 +1,37 @@
# Copyright 2026 jCloud Services GbR
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'''
The command line interface
'''
__all__ = [
'main'
]
import argparse
import pathlib
from .utils import ExistingDirectory
def existing_directory(path: str, *args, **kwargs) -> pathlib.Path:
try:
return ExistingDirectory(path, *args, **kwargs)
except (FileNotFoundError, NotADirectoryError) as e:
raise argparse.ArgumentTypeError(f'{e.filename}{": " + e.args[1] if len(e.args) > 1 else ""}')
def main() -> int:
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('project_directory', type = existing_directory, default = pathlib.Path('.'), help = 'The directory of the project')
args = argument_parser.parse_args()
return 0