Merge "A update alias autocomplete." into main
diff --git a/experiments/a/README.md b/experiments/a/README.md
index e94742a..116e872 100644
--- a/experiments/a/README.md
+++ b/experiments/a/README.md
@@ -5,6 +5,32 @@
Contributions welcome!
+### A and Autocomplete aliases
+Add the following to your ~/.bashrc for autocompletions
+```
+# Alias for local workflow "a update" tool
+a() {
+ python3 "$ANDROID_BUILD_TOP/tools/asuite/experiments/a/a.py" "$@"
+}
+_a_completion() {
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ if [[ ${prev} == "a" ]] ; then
+ COMPREPLY=( $(compgen -W "update" -- ${cur}) )
+ return 0
+ fi
+
+ if [[ ${prev} == "update" ]] ; then
+ COMPREPLY=( $(compgen -W "$(a update --list-aliases)" -- ${cur}) )
+ return 0
+ fi
+}
+complete -F _a_completion a
+```
+
### To Run
```a {config_name}```
or
diff --git a/experiments/a/tools/update.py b/experiments/a/tools/update.py
index ea6663d..39acf87 100644
--- a/experiments/a/tools/update.py
+++ b/experiments/a/tools/update.py
@@ -63,9 +63,19 @@
' targets.'
),
)
+ parser.add_argument(
+ '--list-aliases',
+ action='store_true',
+ help='list aliases; used for autocomplete',
+ )
def main(self):
"""Main entrypoint for Update."""
+
+ if self.args.list_aliases:
+ print(' '.join(get_aliases().keys()))
+ return
+
tasks = self.gather_tasks()
self.run_tasks(tasks)