#!/usr/bin/env python
"""The Gaphor code generator CLI.

Provides the CLI for the code generator which transforms a Gaphor models
(with .gaphor file extension) in to a data model in Python.
"""

import argparse
from distutils.util import byte_compile
from pathlib import Path

from gaphor.codegen import profile_coder, uml_coder


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("modelfile", type=Path, help="gaphor model filename")
    parser.add_argument("outfile", type=Path, help="python data model filename")
    parser.add_argument("overrides", type=Path, help="override filename")
    parser.add_argument(
        "--uml_profile", help="generate a UML profile", action="store_true"
    )
    parser.add_argument(
        "--sysml_profile", help="generate a SysML profile", action="store_true"
    )
    args = parser.parse_args()
    print(f"Generating {args.outfile} from {args.modelfile}...")
    print("  (warnings can be ignored)")
    if args.uml_profile:
        profile_coder.generate(args.modelfile, args.outfile, args.overrides)
    elif args.sysml_profile:
        profile_coder.generate(args.modelfile, args.outfile, args.overrides, True)
    else:
        uml_coder.generate(args.modelfile, args.outfile, args.overrides)
    byte_compile([str(args.outfile)])


if __name__ == "__main__":
    main()

#!/usr/bin/env python
"""The Gaphor code generator CLI.

Provides the CLI for the code generator which transforms a Gaphor models
(with .gaphor file extension) in to a data model in Python.
"""

import argparse
from distutils.util import byte_compile
from pathlib import Path

from gaphor.codegen import profile_coder, uml_coder


def main() -> None:
    parser = argparse.ArgumentParser()
    parser.add_argument("modelfile", type=Path, help="gaphor model filename")
    parser.add_argument("outfile", type=Path, help="python data model filename")
    parser.add_argument("overrides", type=Path, help="override filename")
    parser.add_argument(
        "--uml_profile", help="generate a UML profile", action="store_true"
    )
    parser.add_argument(
        "--sysml_profile", help="generate a SysML profile", action="store_true"
    )
    args = parser.parse_args()
    print(f"Generating {args.outfile} from {args.modelfile}...")
    print("  (warnings can be ignored)")
    if args.uml_profile:
        profile_coder.generate(args.modelfile, args.outfile, args.overrides)
    elif args.sysml_profile:
        profile_coder.generate(
            args.modelfile, args.outfile, args.overrides, includes_sysml=True
        )
    else:
        uml_coder.generate(args.modelfile, args.outfile, args.overrides)
    byte_compile([str(args.outfile)])


if __name__ == "__main__":
    main()

Use positional argument to improve clarity
Use positional argument to improve clarity

Signed-off-by: Dan Yeaw <2591e5f46f28d303f9dc027d475a5c60d8dea17a@yeaw.me>
