Files
2125_GCE/gx_cli/main.py
T

33 lines
646 B
Python
Raw Normal View History

import sys
from .parser import build_parser
from .dispatcher import dispatch
def main(argv=None) -> int:
parser = build_parser()
try:
args = parser.parse_args(argv)
if not args.command:
parser.print_help()
return 1
return dispatch(args)
except SystemExit as e:
if e.code != 0:
return e.code
return 0
except KeyboardInterrupt:
print("\nInterrupted", file=sys.stderr)
return 130
except Exception as e:
print(f"Fatal error: {e}", file=sys.stderr)
return 1
if __name__ == "__main__":
raise SystemExit(main())