This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CLI autocomplete

Hey. Has anybody played with autocomplete for command line interface. I like it alot and it is very helpfull. Now a autocomplete would be cool!

Here is what comes to mind:

  • key as arrows and tab should be treated as return with the same text written again.

  • when is pressed we should compare our last argument with some kind of list.

  • when up and down arrows are pressed we should also go through some history list. I think 5 or 10 are enough.

  • What do you mean not working? When I am flashing this hex to my board I am able to:

    • Execute command: "history"
    • Use up and down arrow to go through history list*
    • Unofrtunately in this version is small bug in the code. If history list is full [0-7] and when you will press up arror until you will see history cmd [0], console will be blocked until you will press enter. This will be fixed with new CLI release.

    What interface are you using? UART, USB or RTT?

  • I'm using RTT. I'm on linux and am using SEGGER J-Link Commander V6.12e for connection to J-Link and telnet localhost 19021 for communication.

    Executing history command works. But on arrow keys i get:

    • nrf_cli:~$ ^[[A^[[A^[[B^[[A^[[B^[[A.

    Maybe this has to do with telnet.

  • So it will be easy from here to make it working as you expect :) My recommendation is to do following in case of RTT:

    • open connection using JLink.exe (not JLink viewer!)
    • as terminal please use Putty. It is the only terminal I found which can be easly configured to handle VT100 escape codes. Mandatory Putty configuration:
    • inside Terminal->Line discipline options-> Local echo and local line editiong set to: "Force off"
    • Terminal->Keybord: you shall have set: Control-H, rxvt, SCO, Normal, Normal
  • I have just tried out what would happend if i pressed two times and press . It did use the two commands back in history. Is this normal behavior? Should i always press enter also after pressing ?

  • Hi, Regarding first concern. Pressing "up" shall print in command line historical command starting from last entered. If command "history" is showing for example:

    • [ 0] cmd_0
    • [ 1] cmd_1
    • [ 2] cmd_2
    • [ 3] cmd_3

    than by pressing "up" you will see cmd_3, "up" again and you will see cmd_2 and so on... But in the example you can observe following bug: if you have commands from [ 0] to [ 7] and if you will press "up" as many times to see what was cmd [ 0] than CLI will be blocked until .

    After pressing copletion shall be done automatically without any additional . If you need to press enter to see completion results it means that your terminal is not correctly configured. I will try to paste my putty settings here.

Related