Skip to content

Commit fa86629

Browse files
Qinghao ShiQinghao Shi
authored andcommitted
EXAMPLES: add list amd Symlink functions
1 parent 2f6f066 commit fa86629

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tools/test/examples/examples.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from argparse import ArgumentParser
2020
import os
2121
from os.path import dirname, abspath, basename
22+
from prettytable import PrettyTable
2223
import os.path
2324
import sys
2425
import subprocess
@@ -53,7 +54,12 @@ def main():
5354
import_cmd.set_defaults(fn=do_import)
5455
clone_cmd = subparsers.add_parser("clone")
5556
clone_cmd.set_defaults(fn=do_clone)
56-
deploy_cmd = subparsers.add_parser("deploy")
57+
list_cmd = subparsers.add_parser("list", help="list examples in config file in a table")
58+
list_cmd.set_defaults(fn=do_list)
59+
symlink_cmd = subparsers.add_parser("symlink", help="create symbolic link to given mbed-os PATH")
60+
symlink_cmd.add_argument("PATH", help=" path of mbed-os to be symlinked")
61+
symlink_cmd.set_defaults(fn=do_symlink)
62+
deploy_cmd = subparsers.add_parser("deploy", help="mbed deploy" )
5763
deploy_cmd.set_defaults(fn=do_deploy)
5864
version_cmd = subparsers.add_parser("tag")
5965
version_cmd.add_argument("tag")
@@ -153,6 +159,18 @@ def do_versionning(args, config, examples):
153159
""" Test update the mbed-os to the version specified by the tag """
154160
return lib.update_mbedos_version(config, args.tag, examples)
155161

162+
def do_list(_, config, examples):
163+
"""List the examples in the config file"""
164+
exp_table = PrettyTable()
165+
exp_table.hrules = 1
166+
exp_table.field_names = ["Name", "Subs", "Feature", "Targets", "Compile", "Test"]
167+
for example in config["examples"]:
168+
exp_table.add_row([example['name'], '\n'.join(example['subs']),'\n'.join(example['features']),'\n'.join(example['targets']),example['compile'],example['test']])
169+
print(exp_table)
170+
return 0
171+
172+
def do_symlink(args, config, examples):
173+
return lib.symlink_mbedos(config, args.path, examples)
156174

157175
if __name__ == "__main__":
158176
sys.exit(main())

0 commit comments

Comments
 (0)