Closed mattytrentini closed 3 weeks ago
Experiments with this feature is coming along nicely now. After re-learning how bash completion scripts work, I discovered that typer has a feature to perform CLI Option autocompletion. It supports everything I wish to do and apparently works on bash/zsh/powershell/fish.
It was pretty easy to implement board, variant and port support - and typer does subcommand and switch autocomplete for free!
So, these currently work:
>mpbuild b<tab>uild
>mpbuild build PYB<tab><tab>
PYBD_SF2 PYBD_SF3 PYBD_SF6 PYBLITEV10 PYBV10 PYBV11
> mpbuild build PYBL<tab>ITEV10
> mpbuild build PYBLITEV10 <tab><tab>
DP DP_THREAD NETWORK THREAD
> mpbuild build PYBLITEV10 DP_<tab>THREAD
> mpbuild build PYBLITEV10 DP_THREAD<enter>
>mpbuild list s<tab><tab>
samd stm32
>mpbuild list st<tab>m32
It still needs a little polish but I'll push it up soon.
I'm satisfied with the solution in #39.
I haven't added the 'optional port syntax' but that can come later.
Adding bash tab completions would be immensely helpful.
build/clean
>mpbuild build nuc[tab][tab]
should list all Nucleo boards.>mpbuild build nucleo_f0[tab]
should complete (withNUCLEO_F091RC
).Consider adding optional port syntax:
>mpbuild build rp2/n[tab]
should complete withNULLBITS_BIT_C_PRO
, ie ignoring all of the Nucleo boards.list
Should probably make the port an optional argument and then the following could be supported:
>mpbuild list s[tab][tab]
would liststm32 samd
,>mpbuild list sa[tab]
would complete withsamd
. The output would then be filtered to that port.Related