mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
feat: add --shell-completions arg for shell completion scripts
This commit is contained in:
parent
9297ee982d
commit
920b20b17d
2 changed files with 20 additions and 0 deletions
|
@ -811,6 +811,18 @@ def get_parser(default_config_files, git_root):
|
||||||
help="Specify which editor to use for the /editor command",
|
help="Specify which editor to use for the /editor command",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
supported_shells_list = sorted(list(shtab.SUPPORTED_SHELLS))
|
||||||
|
group.add_argument(
|
||||||
|
"--shell-completions",
|
||||||
|
metavar="SHELL",
|
||||||
|
choices=supported_shells_list,
|
||||||
|
help=(
|
||||||
|
"Print shell completion script for the specified SHELL and exit. Supported shells:"
|
||||||
|
f" {', '.join(supported_shells_list)}. Example: aider --shell-completions bash"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
##########
|
##########
|
||||||
group = parser.add_argument_group("Deprecated model settings")
|
group = parser.add_argument_group("Deprecated model settings")
|
||||||
# Add deprecated model shortcut arguments
|
# Add deprecated model shortcut arguments
|
||||||
|
|
|
@ -15,6 +15,7 @@ except ImportError:
|
||||||
|
|
||||||
import importlib_resources
|
import importlib_resources
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
import shtab
|
||||||
from prompt_toolkit.enums import EditingMode
|
from prompt_toolkit.enums import EditingMode
|
||||||
|
|
||||||
from aider import __version__, models, urls, utils
|
from aider import __version__, models, urls, utils
|
||||||
|
@ -502,6 +503,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
# Parse again to include any arguments that might have been defined in .env
|
# Parse again to include any arguments that might have been defined in .env
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
if args.shell_completions:
|
||||||
|
# Ensure parser.prog is set for shtab, though it should be by default
|
||||||
|
parser.prog = "aider"
|
||||||
|
print(shtab.complete(parser, shell=args.shell_completions))
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if git is None:
|
if git is None:
|
||||||
args.git = False
|
args.git = False
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue