mirror of
https://github.com/enpaul/glassy.git
synced 2024-11-22 06:26:56 +00:00
Add basic program scaffolding
This commit is contained in:
parent
27ffee9581
commit
3a8b273706
@ -0,0 +1,36 @@
|
||||
"""Main program entrypoint and CLI interface"""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from glassy import __about__
|
||||
|
||||
|
||||
def get_args() -> argparse.Namespace:
|
||||
"""Parse the CLI arguments"""
|
||||
|
||||
parser = argparse.ArgumentParser(prog=__about__.__title__, description=__about__.__summary__)
|
||||
|
||||
parser.add_argument("--version", help="Show program version and exit", action="store_true")
|
||||
parser.add_argument("-c", "--config", help="Path to the program config file", default=Path("~", ".config", "glassy.yaml").resolve())
|
||||
parser.add_argument("--check", help="Check syntax of the config file and diagram without running network tests", action="store_true")
|
||||
parser.add_argument("-o", "--output", help="Path to a file to output the rendered result, or one of the magic values 'stdout' or 'stderr'", default="stdout")
|
||||
parser.add_argument("template", help="Path to the template diagram to render and output")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = get_args()
|
||||
|
||||
if args.version:
|
||||
print(f"{__about__.__title__} {__about__.__version__}", file=sys.stderr)
|
||||
return 0
|
||||
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
Loading…
Reference in New Issue
Block a user