Skip to content

Commit 94313d6

Browse files
committed
Add version command
1 parent 769b3b8 commit 94313d6

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

ahkpy/main.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ def open_docs():
9191

9292

9393
def run_from_args():
94-
usage = "py -m ahkpy [-h] [-q] [--no-tray] [-c CMD | -m MOD | FILE | -] [ARGS] ..."
95-
parser = GUIArgumentParser(usage=usage)
94+
usage = "py -m ahkpy [-h] [-V] [-q] [--no-tray] [-c CMD | -m MOD | FILE | -] [ARGS] ..."
95+
parser = GUIArgumentParser(usage=usage, prog="ahkpy")
96+
parser.add_argument(
97+
"-V", "--version", action="version", version=version(),
98+
)
9699
parser.add_argument(
97100
"-q", "--quiet", action="store_true",
98101
help="suppress message boxes with errors",
@@ -167,6 +170,12 @@ def _print_message(self, message, file=None):
167170
file.write(message)
168171

169172

173+
def version():
174+
python_version, _, _ = sys.version.partition(" ")
175+
ahk_version = ahk.flow.ahk_call("GetVar", "A_AhkVersion")
176+
return f"AutoHotkey.py {ahk.__version__}, Python {python_version}, AutoHotkey {ahk_version}"
177+
178+
170179
def interact():
171180
import code
172181
console = code.InteractiveConsole(locals={"ahkpy": ahk, "ahk": ahk})

docs/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ When invoking AutoHotkey.py, you may specify any of these options:
1616

1717
.. code-block:: text
1818
19-
ahkpy [-h] [-q] [--no-tray] [-c CMD | -m MOD | FILE | -] [args]
19+
ahkpy [-h] [-V] [-q] [--no-tray] [-c CMD | -m MOD | FILE | -] [args]
2020
2121
The most common use case is, of course, a simple invocation of a script:
2222

0 commit comments

Comments
 (0)