Skip to content

Commit 811e2b5

Browse files
bridadansarahmarshy
authored andcommitted
Adding MCU and example filter options to example test CLI
1 parent 79abaab commit 811e2b5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tools/test/examples/examples.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
sys.path.insert(0, ROOT)
1313

1414
from tools.utils import argparse_force_uppercase_type
15+
from tools.utils import argparse_many
16+
from tools.build_api import get_mbed_official_release
1517
import examples_lib as lib
1618
from examples_lib import SUPPORTED_TOOLCHAINS, SUPPORTED_IDES
1719

@@ -21,8 +23,16 @@
2123

2224
def main():
2325
"""Entry point"""
26+
27+
official_targets = get_mbed_official_release("5")
28+
official_target_names = [x[0] for x in official_targets]
29+
30+
2431
parser = ArgumentParser()
2532
parser.add_argument("-c", dest="config", default="examples.json")
33+
parser.add_argument("-e", "--example",
34+
help=("filter the examples used in the script"),
35+
type=argparse_many()
2636
subparsers = parser.add_subparsers()
2737
import_cmd = subparsers.add_parser("import")
2838
import_cmd.set_defaults(fn=do_import)
@@ -39,12 +49,26 @@ def main():
3949
"toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS,
4050
type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS,
4151
"toolchain")),
52+
compile_cmd.add_argument("-m", "--mcu",
53+
help=("build for the given MCU (%s)" %
54+
', '.join(official_target_names)),
55+
metavar="MCU",
56+
type=argparse_many(
57+
argparse_force_uppercase_type(
58+
official_target_names, "MCU")))
4259
export_cmd = subparsers.add_parser("export")
4360
export_cmd.set_defaults(fn=do_export),
4461
export_cmd.add_argument(
4562
"ide", nargs="*", default=SUPPORTED_IDES,
4663
type=argparse_force_uppercase_type(SUPPORTED_IDES,
4764
"ide"))
65+
export_cmd.add_argument("-m", "--mcu",
66+
help=("build for the given MCU (%s)" %
67+
', '.join(official_target_names)),
68+
metavar="MCU",
69+
type=argparse_many(
70+
argparse_force_uppercase_type(
71+
official_target_names, "MCU")))
4872
args = parser.parse_args()
4973
config = json.load(open(os.path.join(os.path.dirname(__file__),
5074
args.config)))

0 commit comments

Comments
 (0)