Skip to content

Commit

Permalink
tools/psoc6/mpy-psoc6.py: Added script version.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Nov 22, 2023
1 parent d1a2663 commit 0d1db1f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/psoc6/mpy-psoc6.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
]

opsys = ""
version = "0.1.0"


def colour_str_success(msg):
Expand All @@ -32,7 +33,7 @@ def set_environment():
opsys = "linux"
elif sys.platform == "win32" or sys.platform == "cygwin":
opsys = "win"
os.system('color')
os.system("color") # Enable colouring in cmd and powershell
elif sys.platform == "darwin":
opsys = "mac"
raise Exception(colour_str_error("OS unsupported"))
Expand Down Expand Up @@ -348,7 +349,7 @@ def device_setup(board, version, update_dbg_fw=False, quiet=False):

if not quiet:
wait_and_request_board_connect()

if update_dbg_fw:
fwloader_download_install()
fwloader_update_kitprog()
Expand Down Expand Up @@ -495,6 +496,16 @@ def parser_device_erase(args):
device_erase(args.board, args.q)

# Main parser
class ver_action(argparse.Action):
def __init__(self, option_strings, dest, **kwargs):
return super().__init__(
option_strings, dest, nargs=0, default=argparse.SUPPRESS, **kwargs
)

def __call__(self, parser, namespace, values, option_string, **kwargs):
print("mpy-psoc6 version: " + version)
parser.exit()

main_parser_desc = """
Micropython PSoC6 utility script
Expand All @@ -510,6 +521,7 @@ def parser_device_erase(args):
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter, description=main_parser_desc
)
parser.add_argument("-v", "--version", action=ver_action, help="mpy-psoc6 version")
subparser = parser.add_subparsers()
parser.set_defaults(func=main_parser_func)

Expand Down

0 comments on commit 0d1db1f

Please sign in to comment.