Skip to content

Commit 9f286c9

Browse files
authored
Merge pull request #721 from ianmcorvidae/shell-completion
Add very simple shell completion using argcomplete
2 parents 749c6a7 + 0b15453 commit 9f286c9

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

meshtastic/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
# later we can have a separate changelist to refactor main.py into smaller files
66
# pylint: disable=too-many-lines
77

8+
from typing import List, Optional, Union
9+
from types import ModuleType
10+
811
import argparse
12+
argcomplete: Union[None, ModuleType] = None
13+
try:
14+
import argcomplete
15+
except ImportError as e:
16+
pass # already set to None by default above
17+
918
import logging
1019
import os
1120
import platform
1221
import sys
1322
import time
14-
from typing import List, Optional
1523

1624
try:
1725
import pyqrcode # type: ignore[import-untyped]
@@ -1961,6 +1969,8 @@ def initParser():
19611969

19621970
parser.set_defaults(deprecated=None)
19631971

1972+
if argcomplete is not None:
1973+
argcomplete.autocomplete(parser)
19641974
args = parser.parse_args()
19651975
mt_config.args = args
19661976
mt_config.parser = parser

poetry.lock

Lines changed: 16 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pyyaml = "^6.0.1"
1616
pypubsub = "^4.0.3"
1717
bleak = "^0.22.3"
1818
packaging = "^24.0"
19+
argcomplete = { version = "^3.5.2", optional = true }
1920
pyqrcode = { version = "^1.2.1", optional = true }
2021
dotmap = { version = "^1.3.30", optional = true }
2122
print-color = { version = "^0.4.6", optional = true }
@@ -64,7 +65,7 @@ ipywidgets = "^8.1.3"
6465
jupyterlab-widgets = "^3.0.11"
6566

6667
[tool.poetry.extras]
67-
cli = ["pyqrcode", "print-color", "dotmap"]
68+
cli = ["pyqrcode", "print-color", "dotmap", "argcomplete"]
6869
tunnel = ["pytap2"]
6970
analysis = ["dash", "dash-bootstrap-components", "pandas", "pandas-stubs"]
7071

0 commit comments

Comments
 (0)