Skip to content

Commit bcef63b

Browse files
committed
docs(args): Add documentation about command line completion
1 parent 76eb8ef commit bcef63b

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

ARCHITECTURE.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ For Bash autocompletion, add this to your `~/.bashrc`:
475475

476476
```bash
477477
eval "$(register-python-argcomplete ardupilot_methodic_configurator)"
478+
eval "$(register-python-argcomplete extract_param_defaults)"
479+
eval "$(register-python-argcomplete annotate_params)"
480+
eval "$(register-python-argcomplete param_pid_adjustment_update)"
481+
eval "$(register-python-argcomplete mavftp)"
478482
```
479483

480484
For Zsh autocompletion, add these lines to your `~/.zshrc`:
@@ -483,17 +487,36 @@ For Zsh autocompletion, add these lines to your `~/.zshrc`:
483487
autoload -U bashcompinit
484488
bashcompinit
485489
eval "$(register-python-argcomplete ardupilot_methodic_configurator)"
490+
eval "$(register-python-argcomplete extract_param_defaults)"
491+
eval "$(register-python-argcomplete annotate_params)"
492+
eval "$(register-python-argcomplete param_pid_adjustment_update)"
493+
eval "$(register-python-argcomplete mavftp)"
486494
```
487495

488496
For PowerShell autocompletion, run this command in PowerShell:
489497

490498
```powershell
491-
Register-ArgumentCompleter -Native -CommandName ardupilot_methodic_configurator -ScriptBlock {
492-
param($wordToComplete, $commandAst, $cursorPosition)
493-
$env:COMP_LINE=$commandAst.ToString()
494-
$env:COMP_POINT=$cursorPosition
495-
ardupilot_methodic_configurator | ForEach-Object {
496-
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
499+
$scripts = @(
500+
'ardupilot_methodic_configurator',
501+
'extract_param_defaults',
502+
'annotate_params',
503+
'param_pid_adjustment_update',
504+
'mavftp'
505+
)
506+
foreach ($script in $scripts) {
507+
Register-ArgumentCompleter -Native -CommandName $script -ScriptBlock {
508+
param($wordToComplete, $commandAst, $cursorPosition)
509+
$command = $script
510+
$env:COMP_LINE = $commandAst.ToString()
511+
$env:COMP_POINT = $cursorPosition
512+
$env:_ARGCOMPLETE = "1"
513+
$env:_ARGCOMPLETE_COMP_WORDBREAKS = " `"`'><=;|&(:"
514+
$env:COMP_WORDS = $commandAst.ToString()
515+
$env:COMP_CWORD = $cursorPosition
516+
517+
(& python -m argcomplete.completers $command) | ForEach-Object {
518+
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
519+
}
497520
}
498521
}
499522
```

windows/argcomplete.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: 2024-2025 Amilcar do Carmo Lucas <amilcar.lucas@iav.de>
2+
3+
# SPDX-License-Identifier: GPL-3.0-or-later
4+
5+
$scripts = @(
6+
'ardupilot_methodic_configurator',
7+
'extract_param_defaults',
8+
'annotate_params',
9+
'param_pid_adjustment_update',
10+
'mavftp'
11+
)
12+
foreach ($script in $scripts) {
13+
Register-ArgumentCompleter -Native -CommandName $script -ScriptBlock {
14+
param($wordToComplete, $commandAst, $cursorPosition)
15+
$command = $script
16+
$env:COMP_LINE = $commandAst.ToString()
17+
$env:COMP_POINT = $cursorPosition
18+
$env:_ARGCOMPLETE = "1"
19+
$env:_ARGCOMPLETE_COMP_WORDBREAKS = " `"`'><=;|&(:"
20+
$env:COMP_WORDS = $commandAst.ToString()
21+
$env:COMP_CWORD = $cursorPosition
22+
23+
(& python -m argcomplete.completers $command) | ForEach-Object {
24+
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)