Vyatta-op completion for files in op-mode definitions

Hi, I’m developing a tool intended to be run on VyOS devices, and as such I’ve delved into op-mode definitions.

I’ve got it mostly working by reading existing defintions, but I’m stuck on one aspect of the <completionHelp> tag.

I’d like to complete on local file paths, specifically targetting readable files.

Commands such as show file uses the <imagePath> tag which seems to be unavailable for <tagNode> (I just get errors while compiling the definitions that it doesn’t match the schema). Not that I’d actually want to use <imagePath> as it’s beyond the scope of this node type’s targeting.

If there is an easy way to use local file paths as <completionHelp>, like bash does for executables like cat, please let me know.

You probably already figured this out, but this was recommended when I was creating a topic recently and figured I’d give an answer so it’ll be available for anyone that finds this later.

You can use the <script> tag to call a script that you put inside of /src/completion/

You would call it with something like this (look at the ‘test123’ tagNode):

<?xml version="1.0" ?>
<interfaceDefinition>
  <node name="connect">
    <children>
      <tagNode name="container">
        <properties>
          <help>Attach to a running container</help>
          <completionHelp>
            <path>container name</path>
          </completionHelp>
        </properties>
        <command>sudo podman exec --interactive --tty &quot;$3&quot; /bin/sh</command>
        <children>
          <tagNode name="test123">
            <properties>
              <help>This is just a test command</help>
              <completionHelp>
                <script>${vyos_completion_dir}/list_test123.sh</script>
              </completionHelp>
            </properties>
            <command>ifconfig</command>
          </tagNode>
        </children>
      </tagNode>
    </children>
  </node>
</interfaceDefinition>

You can create a simple shell script, or if you need something a little more complex, you can also call a python script.