Skip to content

Commit 646fcda

Browse files
committed
tools/mpremote: Add command to print the version.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 5cc2dd4 commit 646fcda

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

tools/mpremote/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2021 Damien P. George
3+
Copyright (c) 2021-2022 Damien P. George
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

tools/mpremote/mpremote/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# empty
1+
__version__ = "0.2.0"

tools/mpremote/mpremote/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
MicroPython Remote - Interaction and automation tool for MicroPython
3-
MIT license; Copyright (c) 2019-2021 Damien P. George
3+
MIT license; Copyright (c) 2019-2022 Damien P. George
44
55
This program provides a set of utilities to interact with and automate a
66
MicroPython device over a serial connection. Commands supported are:
@@ -68,6 +68,7 @@
6868
"run": (True, True, 1, "run the given local script"),
6969
"fs": (True, True, 1, "execute filesystem commands on the device"),
7070
"help": (False, False, 0, "print help and exit"),
71+
"version": (False, False, 0, "print version and exit"),
7172
}
7273

7374
_BUILTIN_COMMAND_EXPANSIONS = {
@@ -109,6 +110,7 @@
109110
"import machine; machine.RTC().datetime((2020, 1, 1, 0, 10, 0, 0, 0))",
110111
],
111112
"--help": "help",
113+
"--version": "version",
112114
}
113115

114116
for port_num in range(4):
@@ -465,6 +467,12 @@ def print_commands_help(cmds, help_idx):
465467
print_commands_help(_command_expansions, 2)
466468

467469

470+
def print_version():
471+
from . import __version__
472+
473+
print(f"{_PROG} {__version__}")
474+
475+
468476
def main():
469477
config = load_user_config()
470478
prepare_command_expansions(config)
@@ -498,6 +506,9 @@ def main():
498506
elif cmd == "help":
499507
print_help()
500508
sys.exit(0)
509+
elif cmd == "version":
510+
print_version()
511+
sys.exit(0)
501512
elif cmd == "resume":
502513
auto_soft_reset = False
503514
continue

0 commit comments

Comments
 (0)