Skip to content

Commit

Permalink
Add CLI options
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc committed Apr 30, 2024
1 parent a2cc7ca commit 71e12ac
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/fprime/fpp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@mstarch
"""

import argparse
from typing import Callable, Dict, List, Tuple

Expand Down Expand Up @@ -57,6 +58,7 @@ def run_fpp_to_xml(
args=({}, ["--directory", parsed.directory] if parsed.directory else []),
)


def run_fpp_to_dict(
build: "Build",
parsed: argparse.Namespace,
Expand All @@ -73,12 +75,19 @@ def run_fpp_to_dict(
__: unused make_args
___: unused pass-through arguments
"""
FppUtility("fpp-to-dict", False).execute(
FppUtility("fpp-to-dict", imports_as_sources=False).execute(
build,
parsed.path,
args=({}, []),
args=(
{},
[
*(["--directory", parsed.directory] if parsed.directory else []),
*(["--size", parsed.size] if parsed.size else []),
],
),
)


def add_fpp_parsers(
subparsers, common: argparse.ArgumentParser
) -> Tuple[Dict[str, Callable], Dict[str, argparse.ArgumentParser]]:
Expand All @@ -97,17 +106,29 @@ def add_fpp_parsers(
check_parser = subparsers.add_parser(
"fpp-check", help="Run fpp-check utility", parents=[common], add_help=False
)
check_parser.add_argument(
check_parser_group = check_parser.add_argument_group("fpp-check arguments")
check_parser_group.add_argument(
"-u", "--unconnected", default=None, help="write unconnected ports to file"
)

fpp_to_xml_parser = subparsers.add_parser(
"fpp-to-xml", help="Run fpp-to-xml utility", parents=[common], add_help=False
)
fpp_to_xml_group = fpp_to_xml_parser.add_argument_group("fpp-to-xml arguments")
fpp_to_xml_group.add_argument("-d", "--directory", help="Output directory")

fpp_to_dict_parser = subparsers.add_parser(
"fpp-to-dict", help="Run fpp-to-dict utility", parents=[common], add_help=False
)
fpp_to_xml_parser.add_argument("--directory", default=None, help="Output directory")
return {"fpp-check": run_fpp_check, "fpp-to-xml": run_fpp_to_xml, "fpp-to-dict": run_fpp_to_dict}, {
fpp_to_dict_group = fpp_to_dict_parser.add_argument_group("fpp-to-dict arguments")
fpp_to_dict_group.add_argument("-d", "--directory", help="Output directory")
fpp_to_dict_group.add_argument("-s", "--size", help="Default string size")

return {
"fpp-check": run_fpp_check,
"fpp-to-xml": run_fpp_to_xml,
"fpp-to-dict": run_fpp_to_dict,
}, {
"fpp-check": check_parser,
"fpp-to-xml": fpp_to_xml_parser,
"fpp-to-dict": fpp_to_dict_parser,
Expand Down

0 comments on commit 71e12ac

Please sign in to comment.