I created a tool to help with XML creation when developing custom op mode commands. The script can be found here:
Detailed usage instructions can be found on the github page.
As an example usage, here is the VyOS article for creating custom commands:
I’m going to recreate one of the commands they created.
We can start with just the outline of the command, which is “show calendar year”. This let’s us see the general format of the command easier. Here would be the basic outline:
show//calendar//!year@
Output
Enter your command: show//calendar//!year@
<?xml version="1.0" ?>
<interfaceDefinition>
<node name="show">
<children>
<node name="calendar">
<children>
<leafNode name="year"/>
</children>
</node>
</children>
</node>
</interfaceDefinition>
Once everything looks good, we can complete the command. Here would be our command:
show//calendar@properties:help=Show the monthly calendar@command:=/usr/bin/cal//!year@properties:help=Show the yearly calendar@command:=/usr/bin/cal -y
Output
Enter your command: show//calendar@properties:help=Show the monthly calendar@command:=/usr/bin/cal//!year@properties:help=Show the yearly calendar@command:=/usr/bin/cal -y
<?xml version="1.0" ?>
<interfaceDefinition>
<node name="show">
<children>
<node name="calendar">
<properties>
<help>Show the monthly calendar</help>
</properties>
<command>/usr/bin/cal</command>
<children>
<leafNode name="year">
<properties>
<help>Show the yearly calendar</help>
</properties>
<command>/usr/bin/cal -y</command>
</leafNode>
</children>
</node>
</children>
</node>
</interfaceDefinition>
Hopefully this is useful to you!