| 1 |
/******************************************************************************* |
|---|
| 2 |
|
|---|
| 3 |
License: Boost Software License, v. 1.0 |
|---|
| 4 |
Academic Free License, v. 3.0 |
|---|
| 5 |
BSD License |
|---|
| 6 |
|
|---|
| 7 |
Authors: Marcin Kuszczak, www.zapytajmnie.com (author's christian site) |
|---|
| 8 |
This software is inspired and partially based on Boost C++ |
|---|
| 9 |
library named 'program_options' and created by Vladimir Prus. |
|---|
| 10 |
|
|---|
| 11 |
Version: 0.9.1 |
|---|
| 12 |
Date: 30-Apr-2008 |
|---|
| 13 |
|
|---|
| 14 |
History: 0.9.0 (08-Oct-2007) - initial public version |
|---|
| 15 |
|
|---|
| 16 |
Description: |
|---|
| 17 |
This example is meant to allow to test response file support |
|---|
| 18 |
in ProgramOptions library. Response file management is built |
|---|
| 19 |
into library, so it does not need additional work for library |
|---|
| 20 |
user. It can be although disallowed by using proper style flag. |
|---|
| 21 |
|
|---|
| 22 |
For a test, build and run: |
|---|
| 23 |
ResponseFile -I foo @ResponseFile.rsp |
|---|
| 24 |
|
|---|
| 25 |
The expected output is: |
|---|
| 26 |
Include paths: foo bar biz |
|---|
| 27 |
|
|---|
| 28 |
******************************************************************************/ |
|---|
| 29 |
|
|---|
| 30 |
import std.stdio; |
|---|
| 31 |
import std.string; |
|---|
| 32 |
import std.file; |
|---|
| 33 |
|
|---|
| 34 |
import doost.util.config.ProgramOptions; |
|---|
| 35 |
import doost.util.config.CommandLineStorage; |
|---|
| 36 |
|
|---|
| 37 |
//------------------------------------------------------------------------------ |
|---|
| 38 |
|
|---|
| 39 |
/******************************************************************************* |
|---|
| 40 |
Program entry point |
|---|
| 41 |
******************************************************************************/ |
|---|
| 42 |
void main(char[][] args) { |
|---|
| 43 |
try { |
|---|
| 44 |
auto desc= new RegularOptions("Allowed options"); |
|---|
| 45 |
desc.options() |
|---|
| 46 |
("help", "produce a help message") |
|---|
| 47 |
("include-path,I", define!(char[][])().composing(), "include path") |
|---|
| 48 |
("magic", define!(int), "magic value") |
|---|
| 49 |
; |
|---|
| 50 |
|
|---|
| 51 |
auto po = (new ProgramOptions).next( |
|---|
| 52 |
(new CommandLineStorage(args, desc)) |
|---|
| 53 |
); |
|---|
| 54 |
|
|---|
| 55 |
po.connect; |
|---|
| 56 |
|
|---|
| 57 |
if ("help" in po) { |
|---|
| 58 |
writefln(desc); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
if ("include-path" in po) { |
|---|
| 62 |
writefln("Include paths: ", po["include-path"].as!(char[][])); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
if ("magic" in po) { |
|---|
| 66 |
writefln("Magic value: ", po["magic"].as!(int)); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
po.disconnect; |
|---|
| 70 |
} |
|---|
| 71 |
catch(ProgramOptionsException e) { |
|---|
| 72 |
writefln(e); |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|