Skip to content

Commit

Permalink
Merge pull request #84 from ARMmbed/devel_list
Browse files Browse the repository at this point in the history
Add --list switch to list all target_id -> platform_name mappings available in mbed-ls
  • Loading branch information
PrzemekWirkus authored Jun 13, 2016
2 parents 4900666 + 3bd3a58 commit b3d2465
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
14 changes: 14 additions & 0 deletions mbed_lstools/lstools_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ def __init__(self):
DETAILS_TXT_NAME = 'DETAILS.TXT'
MBED_HTM_NAME = 'mbed.htm'

def list_manufacture_ids(self):
from prettytable import PrettyTable

columns = ['target_id_prefix', 'platform_name']
pt = PrettyTable(columns)
for col in columns:
pt.align[col] = 'l'

for target_id_prefix in sorted(self.manufacture_ids.keys()):
platform_name = self.manufacture_ids[target_id_prefix]
pt.add_row([target_id_prefix, platform_name])

return pt.get_string()

def mock_read(self):
"""! Load mocking data from local file
@return Curent mocking configuration (dictionary)
Expand Down
12 changes: 11 additions & 1 deletion mbed_lstools/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ def cmd_parser_setup():
action="store_true",
help='Parser friendly verbose mode')

parser.add_option('-l', '--list',
dest='list_platforms',
default=False,
action="store_true",
help='List all platforms and corresponding TargetID values mapped by mbed-ls')

parser.add_option('-m', '--mock',
dest='mock_platform',
help='Add locally manufacturers id and platform name. Example --mock=12B4:NEW_PLATFORM')
Expand Down Expand Up @@ -144,7 +150,7 @@ def cmd_parser_setup():
def mbedls_main():
"""! Function used to drive CLI (command line interface) application
@return Function exits with successcode
@return Function exits with success code
@details Function exits back to command line with ERRORLEVEL
"""
Expand All @@ -160,6 +166,10 @@ def mbedls_main():
if not opts.skip_retarget:
mbeds.retarget()

if opts.list_platforms:
print mbeds.list_manufacture_ids()
sys.exit(0)

if opts.mock_platform:
if opts.mock_platform == '*':
if opts.json:
Expand Down

0 comments on commit b3d2465

Please sign in to comment.