Last updated on July, 15th 2013

CLI toolkit

Latest news

July, 15th 2013 Version 2.8: It took me a while to finalize new major improvements.
Execution contexts and faster python transformation tools.
>>> [changes] [download] <<<
Dec, 9th 2011 Version 2.7: You guys start contributing and that's GREAT!
Text edition facilities, and many other improvements (non blocking execution, telnet...)
Dec, 15th 2010 Version 2.6 release.
...
Oct, 1st 2009 Sourceforge registration >>> [aroyer-cli] <<<
(The main location of the project remains this page).
...
May, 17th 2006 Very first beta release.

Refer to the history section for all changes.

CLI toolkit overview

CLI is a toolkit that allows you to easily implement C++ and Java Command Line Interfaces as below:

XML resource file

<?xml version="1.0"?>
<cli name="Hello" xmlns="http://alexis.royer.free.fr/CLI">
 <cpp option="include">#include "hello.h"</cpp>

 <keyword string="say"><help lang="en">Tell Something.</help>
  <keyword string="hello"><help lang="en">Just say hello.</help>
   <endl><cpp>sayHello();</cpp></endl>
  </keyword>
  <keyword string="bye"><help lang="en">Say goodbye.</help>
   <endl><cpp>sayBye();</cpp></endl>
  </keyword>
 </keyword>
</cli>

CLI execution

This 'Hello world' example shows the direct relationship between the XML resource file and the CLI execution of the user-defined function 'sayHello()' for instance.

Here is list of the main features of the CLI toolkit:

  1. Edition facilities: The user can use left and right arrows, begin and end, delete and backspace keys for command line edition.
  2. History: The user can use up and down arrows to navigate through the command line history.
  3. Completion and help: The user has facilities to get into the set of commands. The CLI toolkit automatically manages completion, and help can be set for every keyword and parameter.
  4. Menus: User-defined commands can give access to user-defined menus, which may contain other sets of user-defined commands, and so on...
  5. XML resource file: All the command lines syntax can be described in an XML resource file, natively managing keywords, parameters, tags... This XML resource file provides the ability to directly insert the final native calls attached to each command, making the link with a global application.
  6. Automatic documentation generation: Based on the XML resource file, the CLI toolkit provides a stylesheet automatically generating CLI documentations.
  7. Generic input/output: Input/output can be easily redirected. The CLI toolkit currently gives support for the following regular input/output devices: console, telnet connections, files and strings. But you may implement your own intput/output device for your special needs.
  8. Traces: An inner traces management system is available with the toolkit.

How does it work?

Considering you already have the user code to execute at end, all you have to do is the following:

  1. Edit an XML resource file;
  2. Transform the XML resource file into target language code;
  3. Integrate the result of the transformation.

Please refer to the user guide for detailed instructions.

Main interests

Here is a list of possible interests you could have in this projects:

License

This open source software, written by Alexis Royer, is provided under BSD-like license.

Changes

History

cli 2.8

Description: New major improvements: execution contexts and faster python transformation tools.
Date: July, 15th 2013
Download:

Download cli 2.8

Major modifications
  • ExecutionContext class creation:
    • Shell ans ui controls improvements
    • NonBlockingKeyReceiver interface removal, NonBlockingIODevice::WaitForKeys() removal
    • TelnetServer redesign
    • PwdShellContext sample
  • Transformation / schema:
    • Systematic source generation
    • python scripts addition (more stable and faster): cli2cpp.py, cli2java.py, cli2help.py
    • XSL stylesheets, schema files and python scripts moved/added in a "tools" directory (backward compatibility with old XSL and schema paths is still provided)
Miscellaneous
  • Makefiles:
    • 'make' and 'make check' dissociation
    • Explicit message when dependencies should be regenerated
    • IfEquals, CheckDir, RemoveDir, CheckSh tool functions addition
  • C++ improvements:
    • Input command lines growing limitation
    • 'explicit' constructors
    • Local protections addition in Cli::SetCli() and Menu::SetMenu() against memory leaks on multiple calls to SetCli()
    • Traces::SafeTrace() improvement, Traces::IsSafe() removal
    • ESCDELAY modification through set_escdelay() correction
  • Java improvements:
    • Useless finalize() methods removal
    • deleteFromNative() gathered in NativeObject for any class
  • Test improvements:
    • Addition of C++ tests/include headers, cli/test/TestTools.java for unit test routines factorization
    • Unit-test makefiles renamed with 'test_' prefix
    • test_tk.mak: Dual execution implementation: USE_STL=yes and USE_STL=no
    • Java test_no_res.mak unit-test addition
  • Documentation:
    • doxygen: msc sequence charts addition, warnings removal
    • javadoc: package documentation
Bug corrections
  • Bug(minor)! C++: Crash in Traces::UnsetStream when streams are unset in the wrong order (trace output consistency improvement)
  • Bug(minor)! C++: telnet unit test does not compile on certain configurations (#include <stdio.h> changed into #include <unistd.h> for close() definition)
  • Bug(minor)! C++: OutputDevice::operator<<(void*) format improvements for better compatibility with 64 bits compilers
  • Bug(minor)! C++: Build info when building in debug under Cygwin
    Info: resolving _ESCDELAY by linking to __imp__ESCDELAY (auto-import)
    Info: resolving _stdscr by linking to __imp__stdscr (auto-import)
    Info: resolving _LINES by linking to __imp__LINES (auto-import)
    Info: resolving _COLS by linking to __imp__COLS (auto-import)
  • Bug(minor)! _mkres.mak: bad force rule on $(CLI_CPP_LIB): dependencies always relink the applications
  • Bug(major)! Java: "Java faile while executing command: 'cls'" => well-known command control 'cls' missing in NativeMenu.cpp
  • Bug(minor)! Java: java.lang.UnsatisfiedLinkError: __Native__getScreenInfo at cli.OutputDevice.__Native__getScreenInfo(Native Method)
    (visible when the getScreenInfo() is called from Java, fixed and checked with I/O devices unit test: java/build/make/io_device.mak, java/src/cli/test/TestIODevice.java)
  • Bug(minor)! Java: Crash on Endl deletion with MenuRef reference set (visible when calling deprecated System.runFinalizersOnExit(true))
  • Bug(minor)! Java: Native object references misfunctionning when declaring twice a same keyword in the same context (fixed and checked with test_no_res.mak)
  • Bug(minor)! Java: Crash when calling deprecated System.runFinalizersOnExit(true) (token addition for static null/stdin/stdout/stderr devices)
  • Bug(minor)! Java: Crash when calling deprecated System.runFinalizersOnExit(true) (no more finalization for TraceClass("CLI_JNI") main instance)
  • Bug(minor)! cli2cpp.xsl/cli2java.xsl: accented character management in T_MkCppName/T_MkJavaName
  • Bug(minor)! cli2java.xsl: Explicit java.lang/java.util package specification (avoid possible conflicts)
  • Bug(minor)! cli2help.xsl: Forward tag commands do not appear in documentation (T_Recursion|CHECK_MENU fix)
  • Bug(minor)! cli2help.xsl: Wrong default description for forward tag options.
  • Bug(minor)! cli2help.xsl: Space missing in command names (due to xsltproc limitation?)
  • Bug(minor)! cli2help.xsl: wrong number of options generated for (a|b)+ patterns while (a|b)* works fine.
    Work around: cli2help.xsl still unfixed, but cli2help.py provides a fix.

cli 2.7

Description: Contributions, text edition facilities and many other improvements.
Date: Dec, 9th 2011
Download:

Download cli 2.7

Major modifications
  • Contributions:
    • Oleg Smolsky: memory leaks + compilation warnings fixes
    • Lakshman Naganoor and Venkatrangan G.: ui::More and ui::Less addition
    • Peter Geremia: 64 bit architecture port
    • Wilson Yu: Xalan and Saxon stylesheet transformation bug
    • Anoop R.: Output interleavings (see FAQ)
  • Text edition facilities:
    • Passwords
    • Text fields
    • Integer fields
    • Yes/no questions
    • Choice questions
  • 'mono-thread' feature renamed into 'non-blocking'
  • Telnet improvements:
    • Use of select() in TelnetServer + TelnetConnection derived from NonBlockingIODevice
    • Full multi-client management
    • StopServer() addition
  • Java Input/output devices refactoring: both Java and native devices implementations, outputDevice constants addition (NULL_KEY, ...), safeness checkings
  • IOMux changed into a sequence of devices (multiple outputs removal)
  • 'cls' command addition
Miscellaneous
  • Input/output devices infinite loops protection improvements with deprecation of GetActualDevice() and addition of WouldOutput()/WouldInput() methods.
  • Traces device management consistency improvements
  • Java implementation completion: StringDevice, TelnetServer and TelnetConnection implementation
  • Shell API modifications (advanced user, see user-guide), fixes for NonBlockingIODevice input devices
  • WinConsole improvements: clean screen and cursor visibility
  • tk::String::ToUpper(), ToLower() methods addition
  • OutputDevice::operator<<(double) smart display
  • Java native sources improvements:
    • NativeExec addition for better thread-safe behaviours
    • NativeObject::GetJavaClassName() completion
    • better ports on 64 bit architectures (to be tested)
  • XSL: Version of CLI library addition in XSL outputs
  • Web page / User guide improvements: FAQ addition, title numbers, dynamic menus, dynamic dialogs
Bug corrections
  • Bug(major)! <tag @ref/> preceding <tag @id/> in sub-nodes causes crashes (correction checked with samples/test/fwd-tag.xml sample)
  • Bug(major)! XSL: '"select" attribute is not allowed on the xsl:call-template element!' XSL transformation error with Saxon (checked also with Xalan) (yuhuawen's contribution integration)
  • Bug(major)! cli2help.xsl fails with Saxon: various XSL syntax errors fixed
  • Bug(major)! <string.h> header missing with g++ version 4.4.4 (ubuntu 10.10): NativeObject.cpp, io_mux.cpp, ncurses_console.cpp, tk.cpp
  • Bug(major)! Misuse of OutputDevice::FreeInstance() return code in Shell::CloseDevices() (major because of possible crashes, never seen however)
  • Bug(minor)! XSL: return cli::... statements do not compile with Visual Studio 6.0

cli 2.6

Description: Patch for CLI 2.5 bugs.
Date: Dec, 15th 2010
Download:

Download cli 2.6

Bug corrections
  • Bug(major)! Do not print intermediate character for errors with no location
  • Bug(major)! Bad XSL generation (C++ and Java) with nested tags (dummy tags among others)
  • Bug(major)! No character output with telnet connections
  • Bug(minor)! Extra /* > */ comments for user code lines
Major modifications
  • Deprecation of SetErrorFormatting(). Use of error handlers instead
  • C++/Java: Shell::GetCurrentMenu(index) method addition
Miscellaneous
  • CPP_DIR, JAVA_DIR, SAMPLES_DIR and WEB_DIR makefile variables removal
  • Documentation makefiles moved in web/build/make
  • Full telnet test implementation

cli 2.5

Description: Schema, automatic documentation, 'members' and 'constructor' sections and 'prompt' handler additions. Plus other stuff.
Date: Sep, 30th 2010
Download:

Download cli 2.5

Major modifications
  • Schema addition: XSD and RelaxNG
  • Automatic documentation of a user CLI
  • 'members' and 'constructor' sections addition
  • 'prompt' handler addition
Miscellaneous
  • Java: _build.mak makefile addition
  • Java: implementation completion (native cli.OutputDevice and cli.IODevice)
  • User-code menu management: Cli::GetMenu() addition and Shell::EnterMenu() declared as public
  • 'error' handler improvement (return value controlling the regular error display)
  • str_LocationSuffix configuration parameter addition
Bug corrections
  • Bug(major)! C++: auto \r on \n missing for telnet connections
  • Bug(minor)! C++: io_device.cpp cast correction for pointer display
  • Bug(minor)! Fatal error when building deps of java/build/make/native.mak under cygwin from make (but direct commands from the shell)
  • Bug(minor)! Do not directly use STL in 'file_device.h'
  • Bug(minor)! XSL: Enable resource names with space characters (menus...)

cli 2.4

Description: Bug corrections & improvements.
Date: Oct, 1st 2009
Download:

Download cli 2.4

Miscellaneous
  • Licensing: URL link addition in the license.
  • Makefile improvements: .DEFAULT_GOAL improvement, include Makefiles prefixed by '_', help and vars dependencies revision
  • C++/Java: 'show version', 'show author' and 'show license' commands addition in the 'cli-config' menu.
  • C++/Java: ALL_STREAMS management in Shell and IOMux.
  • C++/Java: OnError() handler addition.
  • C++: various improvements.
  • C++: stdout and stderr flushing addition for a better rendering.
  • Java: implementation completion (ResourceString and Help revision, IODevice.getLocation(), Shell...)
  • Java: OutputDevice.printStackStrace() method addition for a better output management
  • Java: finalization & native creation improvements
  • Java: cli.jar archive improvement
  • Java: XSL minor comment improvements
  • XSL improvements for other XSLT processor out of xsltproc
Bug corrections
  • Bug(major)! DELETE key management missing in cli::Shell class

cli 2.3

Description: Left and right arrows management. Clean screen management. Plus other stuff.
Date: May, 18th 2009
Download:

Download cli 2.3

Major modifications
  • Left and right arrows management
  • Clean screen function (CTRL+L)
  • Integration improvements: thread safe termination management, mono-thread execution
  • XSL generation improved for a better readability of the code generated: user-code highlighted, and comments addition indicating the current chain of keywords in analysis
Miscellaneous
  • Command line history object addition
  • Input/output character management improvements, "endl" support modification for Input/Output devices. '\n' are automatically interpreted by devices now
  • Input file device improvements: bufferization for optimization, special characters disabling, error location / error prefixing modification
  • Consistency improvements regarding devices: OutputDevice::GetActualDevice() method addition
  • Java samples projects addition
Bug corrections
  • Bug(major)! cppclic.xsl correction for SAXON compatibility
  • Bug(minor)! Errors due to oversized words in CommandLine are not notified to the user
  • Bug(minor)! xsltproc crash when the tag[@ref] is directly located in the tag[@id]

cli 2.2

Description: Bug corrections & improvements
Date: Sep, 21st 2008
Download:

Download cli 2.2

Bug corrections
  • Bug(major)! IOMux device closure error.
  • Bug(major)! cli::tk::Queue::Iterator [tk_stl.h] definition revision. Incompatible with some compilers.
  • Bug(major)! Java object consistency problems.
  • Bug(major)! XSL generation errors for menus directly generated for an endl node.
  • Bug(major)! Bad cppclic.xsl generation for 2 level menu structures.
  • Bug(major)! Memory leak in Queue::~Queue() [tk_inner.h] -> m_arptQueue was not destroyed.
  • Bug(major)! Consistency errors because of static constant objects in C++ files when compiled with Visual .NET. Singleton used instead.
  • Bug(major)! Bad javaclic.xsl generation for 2 level menu structures. Test addition.
  • Bug(major)! History cannot store more than 100 command lines
  • Bug(minor)! InputFileDevice::GetKey(): unknown characters do not end the file anymore.
  • Bug(minor)! Spelling error: "Uncomplete" changed to "Incomplete" in CommandLine::Parse().
  • Bug(minor)! System includes (#include <>) changed into project includes (#include "").
  • Bug(minor)! When an input file does not exist (cli::InputFileDevice), no error message is printed out. => Addition of a m_cliLastError member in cli::OutputDevice, that can be set by all subclasses.
  • Bug(minor)! TAB when the line is empty does nothing.
Miscellaneous
  • Makefile improvements.
  • Special character addition.
  • Addition of error prefixing.
  • Cli configuration menu disabling
  • Java implementation evolutions: cli.Element.getCli/getShell(), cli.Traces.set/unsetStream(), cli.IOMux, cli.SingleCommand
  • Java documentation.
  • Doxygen documentation generated in web directory.
  • XSL stylesheet revision: special sections, CLI_EXECUTION, cpp corrections, coherence between cpp and java...

cli 2.1

Description: Java support and various improvements.
Date: Oct, 31st 2007
Download:

Download cli 2.1

Major modifications
  • Java support: lots of improvements still remaining, but it works so far
  • French language support
Miscellaneous
  • C++:
    • Makefile architecture improvements: help.mak, mkres.mak, check.mak... makefiles creation
    • Addition of cli::Object generic object
    • No namespace directive enabled
    • No-stdlib implementation available
    • Pre-compiled headers enabling
    • Assertions improvements
    • ncurses and Windows consoles modifications
    • Traces consistency improvement. Addition of Traces::UnsetStream()
    • XSL revisions (inherited from java experience): CLI tree created in the scope of the CLI class; Both static and dynamic CLI instantiation; Generation of CLI_EXECUTION traces

cli 2.0

Description: License modification.
Date: Sept, 27th 2007
Download:

Download cli 2.0

Major modifications
  • License modification: The former LGPL license has been abandoned for a BSD-like license. This is the decision of the author (myself) in order to have fewer constraints on using and modifying the toolkit in any kind of softwares (even commercial ones), which is what I wanted initially.
Miscellaneous
  • Useless constructor removal in cli/include/param.h

cli 1.0

Description: Not a beta anymore! Improved again, and fully C++ coding now.
Date: Apr, 30th 2007
Download:

Download cli 1.0

Major modifications
  • cli namespace.
  • Input / output devices:
    • instance and opening locking / auto-deletion
    • new devices: cli::FileDevice, cli::SingleCommand, cli::IOMux
  • Revision of cpp section naming in XSL.
Miscellaneous
  • include/cli directory creation and file names modification.
  • Makefiles improvements:
    • build/make directory creation
    • target specific generation
    • debug generation management
    • BIN_SUFFIX addition
  • Unit tests: empty, io_device.
  • Traces system addition.
Bug corrections
  • Bug(major)! No help display on completion so far.
  • Bug(major)! Bad management of '%' and '|' characters.
  • Bug(major)! Incorrect behavior on a string parameters filled with "" (completion and execution, as if not set).
  • Bug(major)! Not possible to have two tags on the same syntax node.
  • Bug(critical)! Crash on CcliOutputDevice::operator<<(const char* const) with NULL for parameter.
  • Bug(major)! Scenario: prompt stream disabled, Echo enabled, TAB for help display => current line not printed again.

cli 1.0.beta1

Description: This version has been improved a lot, and tested on both Linux and Windows.
Date: Sept, 27th 2006
Download:

Download cli 1.0.beta1

Major modifications
  • Source documentation.
  • Windows / cygwin support (Linux is still available of course).
  • Command line history.
  • Completion "so far".
  • Escape characters and double quotes management.
  • Hollow-tags.
  • Beep support for IO devices.
  • Stream branching modification.
  • Welcome and prompt messages modification.
  • Echo and beep on/off live configuration.
Miscellaneous
  • User-defined includes generated in the very first place (useful for pre-compiled headers).
  • '?' / TAB, help / completion behaviors improvement.
  • Launch method modification.
  • CLI retrieval based on regular expressions.
  • Automatic test tools.
  • C++ constness improvement.
  • Cross-platform Makefiles improvement.
Bug corrections
  • Bug(minor)! A new line is not printed anymore on unsuccessful tab request.
  • Bug(minor)! The line is not printed anymore when a syntax error occurred.
  • Bug(minor)! Xml-namespace fixed.
  • Bug(minor)! Elements sorted for help display.
  • Bug(minor)! "Syntax error next to..." not correctly displayed on completion.
  • Bug(minor)! Double definition of CcliElement::FindElements() fixed.

cli 1.0.beta1-1

Description: Very first release. I still propose it for download for history purpose only. Quite stable, but needs little adaptation to work under Windows for instance. Let's say it was ready for demonstration.
Date: May, 17th 2006
Download:

Download cli 1.0.beta1-1

The following charts gives the evolution of the number of code lines throughout the time:

Next evolutions

To my point of view, the major aims of the CLI toolkit have been reached so far, and I'm quite proud of that. That's the reason why there are not many modifications expected in the next times. But once again, if you feel the need for any other evolution, please .

Coming next:

Download

Latest version of the CLI toolkit is 2.8. Please refer to history section for previous downloads.

Download cli 2.8 now!

The CLI toolkit is also available for download on Sourceforge.

Contact

Any question? Found a bug? Feel free to .