clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
208 stars 70 forks source link

Add support for -V option to give version #472

Closed pprindeville closed 7 months ago

pprindeville commented 8 months ago

Rather than doing echo -e "show version\nexit\n" | clixon_cli it would be nicer to just have clixon_cli -V give an answer.

That said, the version string should be one provided by the developer, not simply CLIXON_VERSION_STRING, etc.

olofhagsand commented 8 months ago

One complexity is plugins must be loaded before callbacks are called. This means that you need to have a proper install, configuration-file etc. You cant just type clixon_cli -V on a bare binary. One could consider a simpler variant just returning CLIXON_VERSION_STRING and exit. Or alternatively, always printing CLIXON_VERSION_STRING forst and then trying to print any callback output. If that would fail (eg on an uninstalled system) it just quits after the version print. The drawback with that would be that you would always get that printout, you could not customize it. @pprindeville ?

olofhagsand commented 8 months ago

Also, should version string be printed on stderr ot stdout?

pprindeville commented 8 months ago

Working backwards, I'd print to stdout because it's not a error, and I might want capture it in $(...) anyway.

What about an external static pointer to a string constant that the user is required to set?

olofhagsand commented 8 months ago

stdout: OK static ptr: No, same problem, still need to load plugin code (where the static pointer points to), and in order to find the plugin code you need the config file.

olofhagsand commented 8 months ago

Committed -V with first a mandatory CLIXON_VERSION followed by customized plugin callbacks.