summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2022-06-07 23:22:04 +1000
committerDamien George <damien@micropython.org>2022-06-07 23:22:04 +1000
commit646fcdadbfc03c8ab3c0720ef1e656786345f258 (patch)
treebe5b1f9d76b152f065b312d93629112fa97148ee
parent5cc2dd4f5d708ded1ceb05d7755c004e4fec7295 (diff)
tools/mpremote: Add command to print the version.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--tools/mpremote/LICENSE2
-rw-r--r--tools/mpremote/mpremote/__init__.py2
-rw-r--r--tools/mpremote/mpremote/main.py13
3 files changed, 14 insertions, 3 deletions
diff --git a/tools/mpremote/LICENSE b/tools/mpremote/LICENSE
index 5ec904cca..a9ea6c27e 100644
--- a/tools/mpremote/LICENSE
+++ b/tools/mpremote/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2021 Damien P. George
+Copyright (c) 2021-2022 Damien P. George
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/tools/mpremote/mpremote/__init__.py b/tools/mpremote/mpremote/__init__.py
index 1bb8bf6d7..d3ec452c3 100644
--- a/tools/mpremote/mpremote/__init__.py
+++ b/tools/mpremote/mpremote/__init__.py
@@ -1 +1 @@
-# empty
+__version__ = "0.2.0"
diff --git a/tools/mpremote/mpremote/main.py b/tools/mpremote/mpremote/main.py
index ccf174bb5..4d74743aa 100644
--- a/tools/mpremote/mpremote/main.py
+++ b/tools/mpremote/mpremote/main.py
@@ -1,6 +1,6 @@
"""
MicroPython Remote - Interaction and automation tool for MicroPython
-MIT license; Copyright (c) 2019-2021 Damien P. George
+MIT license; Copyright (c) 2019-2022 Damien P. George
This program provides a set of utilities to interact with and automate a
MicroPython device over a serial connection. Commands supported are:
@@ -68,6 +68,7 @@ _COMMANDS = {
"run": (True, True, 1, "run the given local script"),
"fs": (True, True, 1, "execute filesystem commands on the device"),
"help": (False, False, 0, "print help and exit"),
+ "version": (False, False, 0, "print version and exit"),
}
_BUILTIN_COMMAND_EXPANSIONS = {
@@ -109,6 +110,7 @@ _BUILTIN_COMMAND_EXPANSIONS = {
"import machine; machine.RTC().datetime((2020, 1, 1, 0, 10, 0, 0, 0))",
],
"--help": "help",
+ "--version": "version",
}
for port_num in range(4):
@@ -465,6 +467,12 @@ def print_help():
print_commands_help(_command_expansions, 2)
+def print_version():
+ from . import __version__
+
+ print(f"{_PROG} {__version__}")
+
+
def main():
config = load_user_config()
prepare_command_expansions(config)
@@ -498,6 +506,9 @@ def main():
elif cmd == "help":
print_help()
sys.exit(0)
+ elif cmd == "version":
+ print_version()
+ sys.exit(0)
elif cmd == "resume":
auto_soft_reset = False
continue