Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add very simple shell completion using argcomplete #721

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
# later we can have a separate changelist to refactor main.py into smaller files
# pylint: disable=too-many-lines

from typing import List, Optional, Union
from types import ModuleType

import argparse
argcomplete: Union[None, ModuleType] = None
try:
import argcomplete
except ImportError as e:
pass # already set to None by default above

Check warning on line 16 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L15-L16

Added lines #L15 - L16 were not covered by tests

import logging
import os
import platform
import sys
import time
from typing import List, Optional

try:
import pyqrcode # type: ignore[import-untyped]
Expand Down Expand Up @@ -1961,6 +1969,8 @@

parser.set_defaults(deprecated=None)

if argcomplete is not None:
argcomplete.autocomplete(parser)
args = parser.parse_args()
mt_config.args = args
mt_config.parser = parser
Expand Down
18 changes: 16 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pyyaml = "^6.0.1"
pypubsub = "^4.0.3"
bleak = "^0.22.3"
packaging = "^24.0"
argcomplete = { version = "^3.5.2", optional = true }
pyqrcode = { version = "^1.2.1", optional = true }
dotmap = { version = "^1.3.30", optional = true }
print-color = { version = "^0.4.6", optional = true }
Expand Down Expand Up @@ -64,7 +65,7 @@ ipywidgets = "^8.1.3"
jupyterlab-widgets = "^3.0.11"

[tool.poetry.extras]
cli = ["pyqrcode", "print-color", "dotmap"]
cli = ["pyqrcode", "print-color", "dotmap", "argcomplete"]
tunnel = ["pytap2"]
analysis = ["dash", "dash-bootstrap-components", "pandas", "pandas-stubs"]

Expand Down
Loading