Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benibela/rcmdline
Advanced command line parser for Pascal
https://github.com/benibela/rcmdline
command-line library parse pascal
Last synced: about 7 hours ago
JSON representation
Advanced command line parser for Pascal
- Host: GitHub
- URL: https://github.com/benibela/rcmdline
- Owner: benibela
- Created: 2013-06-08T21:39:04.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-04-30T18:11:05.000Z (over 1 year ago)
- Last Synced: 2024-11-15T13:44:25.903Z (2 months ago)
- Topics: command-line, library, parse, pascal
- Language: Pascal
- Size: 166 KB
- Stars: 39
- Watchers: 8
- Forks: 19
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
TCommandLineReader
==================
This unit provides an advanced, platform-independent command line parser for Lazarus and Delphi.It checks for allowed options, automatically prints a help with a list of all of them, and -- contrary to the parser in the rtl -- behaves the same on Windows and Linux.
Example:
```pascal
var cmdline: TCommandLineReader;
begin
cmdline := TCommandLineReader.create;
//Initial declaration of some command line parameters:
cmdline.declareString('name', 'An example string property');
cmdline.declareString('foo', 'Another example string property', 'bar');
cmdline.declareInt('count', 'An example integer property', 123);
cmdline.declareFlag('flag', 'An example boolean property');
//cmdline.parse();
//1. Parsing some command line options
cmdline.parse('--name="some name" --count 9');
cmdline.readString('name'); //some name
cmdline.readString('foo'); //bar
cmdline.readInt('count'); //9
cmdline.readFlag('flag'); //false
cmdline.existsProperty('name'); //true
cmdline.existsProperty('foo'); //false
//2. Parsing some other command line options
cmdline.parse('--foo barbar --flag');
cmdline.readString('name'); //
cmdline.readString('foo'); //barbar
cmdline.readInt('count'); //123
cmdline.readFlag('flag'); //true
cmdline.existsProperty('name'); //false
cmdline.existsProperty('foo'); //true//3. Parsing some other command line options
cmdline.parse('--help');
//prints automatically generated help to stdout and halts:
{
The following command line options are valid:--name= An example string property
--foo= Another example string property (default: bar)
--count= An example integer property (default: 123)
--flag An example boolean property
}//4. Some more advanced usage
cmdline.addAbbreviation('f'); //abbreviation for the last option (--flag)
cmdline.allowDOSStyle := true; //DOS slash options. Default is only true on Windows
cmdline.parse('/name "x y z" -f /count=1 /foo="abc"');
cmdline.readString('name'); //x y z
cmdline.readString('foo'); //abc
cmdline.readInt('count'); //1
cmdline.readFlag('flag'); //true
cmdline.existsProperty('name'); //true
cmdline.existsProperty('foo'); //true
```See my webpage for the detailed [rcmdline documentation](http://www.benibela.de/sources_en.html#rcmdline)