Sep 26, 2017, 10:50 PM
Post #1 of 4
Creating a tool which has a CLI
Wondering if its possible to create a tool with perl that has its own CLI? Maybe perl isn't the right language for it, but my idea is basically a XML editor which allows users to interactively modifiy their file. Now I know there are existing GUI's out there, but they don't have some of the features I want to incorporate. For example lets say my tool is called xml_editor_1.0
Run from UNIX/LINUX command line:
% xml_editor_1.0 -cli
Now the tool is 'loaded':
I'm thinking then the user can 'read' the xml file which opens an existing XML file and loads the root node. Any further actions taken will be done on the loaded XML. I will also XML::libXML (or similar) as a base to create all of the unique tool commands.
xml_editor_1.0> read <path_to_XML_file>
Or lets say user wants to create a new file, it would use the schema as a framework to create an 'empty' file:
xml_editor_1.0> create -xml my_new_xml.xml
Then from there if they want to add or remove major elements they can do it through some custom made commands. Below are some random examples, although there are a ton of other different actions I would want to incorporate as well:
xml_editor_1.0> add -element blablah <-- creates a new element
xml_editor_1.0> delete -element blahblah <-- remove element
xml_editor_1.0> edit -element name <-- edit field of elemnent
xml_editor_1.0> save my_new_xml2.xml <-- save current xml database to new file
xml_editor_1.0> create -pdf -root my_new_xml2.xml <-- creates other output types
xml_editor_1.0> validate -xml my_new_xml2.xml <-- makes sure complies to schema
xml_editor_1.0> convert -xml my_new_xml2.xml <-- converts other schemas into local schema
This is a few basic commands but I have thought up a ton of other commands which would be useful in my application. I also think it would be cool if I could somehow incorporate PERL syntax to allow users to create their own loops and variables to automate the creation/editing process. Eventually I'm hoping to create a GUI for this as well so people can choose between running on the tool CLI or doing things through the GUI.
So is this possible via perl, or should I be looking elsewhere?