Cmd module: completion of the first word

I use completedefault( see document ) to complete using the module Cmd. But it seems that this is called only after the first word.

def completedefault(self,text,line,begidx,endidx):                                          
     print('completedefault is called')                                                      
     return ['foo','bar']

Output:

(Cmd) f<Tab><Tab>
(Cmd) foo f<Tab><Tab>
completedefault is called
foo bar

How to change this behavior so that it is called even at the first word?

+4
source share
1 answer

The answer is really simple: Cmd.completenames. More details here . A similar question is here .

+2
source

Source: https://habr.com/ru/post/1534160/


All Articles