Skip to content

Commit

Permalink
Add fpp-to-dict wrapper command (#200)
Browse files Browse the repository at this point in the history
* Add fpp-to-dict with no CLI options

* Add CLI options
  • Loading branch information
thomas-bc authored May 7, 2024
1 parent 17f7d14 commit 42b5308
Showing 1 changed file with 49 additions and 3 deletions.
52 changes: 49 additions & 3 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 @@ -58,6 +59,35 @@ def run_fpp_to_xml(
)


def run_fpp_to_dict(
build: "Build",
parsed: argparse.Namespace,
_: Dict[str, str],
__: Dict[str, str],
___: List[str],
):
"""Run the fpp-to-xml utility
Args:
build: build directory output
parsed: parsed input arguments
_: unused cmake_args
__: unused make_args
___: unused pass-through arguments
"""
FppUtility("fpp-to-dict", imports_as_sources=False).execute(
build,
parsed.path,
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 @@ -76,14 +106,30 @@ 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_parser.add_argument("--directory", default=None, help="Output directory")
return {"fpp-check": run_fpp_check, "fpp-to-xml": run_fpp_to_xml}, {
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_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,
}

0 comments on commit 42b5308

Please sign in to comment.