Skip to content

Commit a6e243d

Browse files
committed
update cli options
1 parent b5d2dbe commit a6e243d

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

__main__.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
#!/usr/bin/python3
22
# coding=utf-8
33

4+
# MIT License
5+
# Copyright (c) 2026 github0null
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
424
from pathlib import Path
525
import click
626
import os
@@ -12,6 +32,7 @@
1232
from pyocd.core.memory_map import MemoryType
1333
from pyocd.target.pack.cmsis_pack import (CmsisPack)
1434

35+
app_version = "v0.1.9"
1536

1637
class CommentedTreeBuilder(ElementTree.TreeBuilder):
1738
def comment(self, data):
@@ -40,17 +61,20 @@ def pretty_xml(element, indent, newline, level=0):
4061

4162

4263
@click.command()
43-
@click.option('--xml-path', '-x', default=None, type=click.STRING, help='jlink xml file path')
64+
@click.option('--jlink-dir', '-j', default=None, type=click.STRING, help='jlink root dir. if not set, it will auto search in system path')
4465
@click.argument('pack_path')
45-
def main(pack_path: str, xml_path: str):
66+
def main(pack_path: str, jlink_dir: str):
4667
"""Import MCU Database From Cmsis Packages To JLink"""
4768

4869
if pack_path == None:
4970
raise Exception('We need a cmsis .pack path !')
5071

51-
if xml_path == None:
72+
xml_path = None
73+
if jlink_dir == None:
5274
p_jlink = find_exe('jlink')
5375
xml_path = os.path.dirname(p_jlink) + '/' + 'JLinkDevices.xml'
76+
else:
77+
xml_path = jlink_dir + '/' + 'JLinkDevices.xml'
5478

5579
if not os.path.isabs(xml_path):
5680
xml_path = os.path.abspath(xml_path)
@@ -118,7 +142,7 @@ def main(pack_path: str, xml_path: str):
118142
if not has_comment_header:
119143
has_comment_header = True
120144
xml_dom_db.append(ElementTree.Comment(''))
121-
xml_dom_db.append(ElementTree.Comment(' {} ({}) (add by \'jlink-dev-addon\', author: github0null) '.format(vendor_name, dev_familys[0])))
145+
xml_dom_db.append(ElementTree.Comment(f" {vendor_name} ({dev_familys[0]}) (add by jlink-dev-addon {app_version})"))
122146
xml_dom_db.append(ElementTree.Comment(''))
123147

124148
n_ele = SubElement(xml_dom_db, 'Device')

0 commit comments

Comments
 (0)