Command Line Component

Discuss any 3rd-party tools and code that may be of interest to other Juce users

Command Line Component

Postby haydxn » Thu Oct 12, 2006 2:38 pm

You're right jules, one a day! :hihi:

This morning's challenge: old school flavour

This is in two parts, heavily commented and very easy to use.

CommandLineSystem forms a base that defines what the command line can do. CommandLineComponent provides a text output space and a user input field.

Demo: CommandLineTest windows build
Source: CommandLine source & VC++e project

Lots of stuff is done automatically. The system has a startup message, 'help' keywords (which display the known commands), an array of known commands, automatic separation of a command from its parameters, the option to keep the command as a single string, optional ignoring of unknown parameters, etc...

A virtual 'processCommand' function is called with the command [string], parameters [string array] and the originating CommandLineComponent's pointer. If you've set it to ignore unknown commands, this will only be called for known commands. This is where you define the behaviour of your system.

If you've set it to preserve the command string, the splitting into command/parameters is not done, and the command (and the pointer to the component) is passed to the virtual 'processCommandString' function.

See the comments for more information.
User avatar
haydxn
JUCE UberWeenie
 
Posts: 1175
Joined: Sun Apr 10, 2005 2:46 pm
Location: Manchester, UK

Postby haydxn » Thu Oct 12, 2006 3:25 pm

Obviously it's probably a bit pointless, but i figured it would be a bit of fun. Plus, loads of apps still have command line interfaces somewhere in them (e.g. matlab, games with a console, etc).

Perhaps it could be used as a kind of 'interactive debugger' feature that could be added to release builds (with some kind of access mechanism) which could be used to output registered variable values.

Or maybe a text adventure :hihi:
xh
User avatar
haydxn
JUCE UberWeenie
 
Posts: 1175
Joined: Sun Apr 10, 2005 2:46 pm
Location: Manchester, UK

Postby valley » Fri Oct 13, 2006 4:52 am

actually, two days ago this would have saved me a few minutes.

I often knock together 15 minute apps[1], and while most of the time I'll use perl, lua, or matlab to get myself out of trouble, I might start doing a few more in command lined JUCE.

Typically I avoid command line stuff with windows cos it is a pain to have a Win32 GUI app also sport a command line.


[1] that's how long they are used for, not how long it takes to write them. :evil:
valley
JUCE UberWeenie
 
Posts: 678
Joined: Sat Sep 04, 2004 4:32 am
Location: Chicago


Return to Useful Tools and Components

Who is online

Users browsing this forum: No registered users and 0 guests