palaniyappanBala / klish

Automatically exported from code.google.com/p/klish
Other
0 stars 0 forks source link

Feature request: Run external command to dynamicaly generate PTYPES #110

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Say for example you have something like this:

<VIEW name="configure-view">
        <COMMAND name="phonegroup"
                help="Select a phonegroup to configure"
                view="configure-phonegroup-view"
                viewid="phonegroup=${phonegroup}">
                <PARAM name="phonegroup"
                       help="Phonegroup Name"
                       ptype="STRING"/>
        </COMMAND>
</VIEW>

you enter the configure view and type phonegroup, hit tab and get the following:
(config)# phonegroup
  String  Phonegroup Name

What I would like to do, is actually list out all phonegroups (or whatever i'm 
configuring), for quick tab completion.

It would be great to be able to define a new PTYPE, where instead of a fixed 
pattern, it ran a command instead, that will return the possibilities for that 
PTYPE.

What I would like to be able to do, is type phonegroup, hit tab, and see

(config)# phonegroup
  String  Phonegroup Name (foo, bar, bin, baz, xyz)

So then I could type 
(config)# phonegroup x <tab>

and it would complete it to be xyz

Original issue reported on code.google.com by koba...@gmail.com on 29 Feb 2012 at 5:45

GoogleCodeExporter commented 8 years ago
so maybe a new PTYPE method can be added, method="command" and then specify 
command="/path/to/script"

It would return a list of possible completions in a specific format.  klish 
would have to check against the list of completions for tab completion 
candidates.

Original comment by koba...@gmail.com on 29 Feb 2012 at 5:53

GoogleCodeExporter commented 8 years ago
To create script generated completion you can use dynamic variables and 
"completion" field of PARAM tag.

<VAR name="ETH"
        help="Ethernet interfaces system prefix"
        value="eth"/>

<VAR name="POSSIBLE_ETH"
        help="Displays possible ethernet numbers (with VLANs)" dynamic="true">
<ACTION>
iface-possible ${ETH}
</ACTION>
</VAR>

<PARAM name="sifnum" ptype="IFACE_NUM" help="Interface number" 
completion="${POSSIBLE_IFACE}"/>

Original comment by serj.kalichev@gmail.com on 29 Feb 2012 at 7:26