gruel.subgruel API documentation

# gruel.subgruel

View Source

     1import argparse
     2
     3from pathier import Pathier
     4
     5root = Pathier(__file__).parent
     6
     7
     8def get_args() -> argparse.Namespace:
     9    parser = argparse.ArgumentParser()
    10
    11    parser.add_argument(
    12        "name",
    13        type=str,
    14        help=""" The name to use for the created file stem and the Gruel subclass name. """,
    15    )
    16    args = parser.parse_args()
    17
    18    return args
    19
    20
    21def main(args: argparse.Namespace | None = None):
    22    if not args:
    23        args = get_args()
    24    content = (
    25        (root / "template.py").read_text().replace("SubGruel", args.name.capitalize())
    26    )
    27    (Pathier.cwd() / f"{args.name.lower()}.py").write_text(content)
    28
    29
    30if __name__ == "__main__":
    31    main(get_args())

def get_args() -> argparse.Namespace: View Source

     9def get_args() -> argparse.Namespace:
    10    parser = argparse.ArgumentParser()
    11
    12    parser.add_argument(
    13        "name",
    14        type=str,
    15        help=""" The name to use for the created file stem and the Gruel subclass name. """,
    16    )
    17    args = parser.parse_args()
    18
    19    return args

def main(args: argparse.Namespace | None = None): View Source

    22def main(args: argparse.Namespace | None = None):
    23    if not args:
    24        args = get_args()
    25    content = (
    26        (root / "template.py").read_text().replace("SubGruel", args.name.capitalize())
    27    )
    28    (Pathier.cwd() / f"{args.name.lower()}.py").write_text(content)