refactor(cli)!: make CLI a package

This commit is contained in:
jakob.scheid committed 2026-09-05 20:38:59 +02:00
1 parent 2d6de2028f
commit 350f8f9941
2 files changed
+19

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
# Copyright 2026 jCloud
# 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
def existing_directory(path: str) -> pathlib.Path:
_path = path
path = pathlib.Path(_path)
if not path.exists():
raise argparse.ArgumentTypeError(f'{_path}: no such file or directory')
if not path.is_dir():
raise argparse.ArgumentTypeError(f'{_path}: not a directory')
return path
def main() -> int:
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('project_directory', type = existing_directory, nargs = '?', default = pathlib.Path('.'), help = 'The directory of the project')
argument_parser.add_argument('-o', '--output-dir', type = pathlib.Path, help = 'the output directory the documentation will be written to')
args = argument_parser.parse_args()
if args.output_dir is None:
args.output_dir = args.project_directory / 'docs/reference'
return 0