cli
Functions and definitions useful when working with ArgumentParser.
Attributes:
-
ArgumentCmdParser(TypeAlias) –generic type of a subparser of the ArgumentParser class.
Attributes
ArgumentCmdParser
module-attribute
ArgumentCmdParser: TypeAlias = _SubParsersAction
Functions
existing_dir
existing_dir(path: str | Path)
Check if path points to an existing directory.
Example:
from argparse import ArgumentParser
from ipsl_common.cli import existing_dir
parser = ArgumentParser()
parser.add_argument("file", type=existing_dir)
Parameters:
-
(pathstr | Path) –path to a directory
Source code in ipsl_common/cli.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
existing_file
existing_file(path: str | Path)
Check if path points to an existing file.
Example:
from argparse import ArgumentParser
from ipsl_common.cli import existing_file
parser = ArgumentParser()
parser.add_argument("file", type=existing_file)
Parameters:
-
(pathstr | Path) –path to a file
Source code in ipsl_common/cli.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |