14#include <boost/optional.hpp>
29 Options() : mDebug(false), mTest(false)
33 bool readOptions(
int argc,
char* argv[]);
56 std::string mInputFile;
61 Options::readOptions(
int argc,
char* argv[])
63 bool help =
false, err =
false;
65 for (
int x = 1; x < argc && !help && !err; ++x)
67 if (argv[x][0] ==
'-' && argv[x][1] ==
'-' && argv[x][2] != 0)
70 std::string opt(argv[x] + 2);
76 else if (opt ==
"test")
80 else if (opt ==
"help")
87 cerr <<
"Unknown option " << argv[x] <<
", use -? for help." << endl;
90 else if (argv[x][0] ==
'-')
93 const char* i = argv[x] + 1;
95 while (*i != 0 && !help && !err)
109 cerr <<
"Uknown option flag '" << *i
121 if (mInputFile.empty())
123 mInputFile = argv[x];
128 cerr <<
"Too many parameters. Already had '" << mInputFile <<
"', found '"
129 << argv[x] <<
"' too. Use -? for help." << endl;
152 const char* cHelpScreen =
153 "This program converts input (from an input file or stdin) from Markdown syntax\n"
154 "to HTML using the cpp-markdown library.\n"
157 " cpp-markdown [<option>...] [input-file]\n"
159 "Available options are:\n"
160 " -?, --help Show this screen.\n"
161 " -d, --debug Show tokens instead of HTML output.\n";
162 cerr << endl << cHelpScreen << endl;
172 if (!cfg.readOptions(argc, argv))
183 std::istream* in = &std::cin;
185 if (!cfg.inputFile().empty())
187 cerr <<
"Reading file '" << cfg.inputFile() <<
"'..." << endl;
188 ifile.open(cfg.inputFile().c_str());
192 cerr <<
"Error: Can't open file." << endl;
202 cerr <<
"Reading standard input..." << endl;
void write(std::ostream &)
void writeTokens(std::ostream &)
bool read(const std::string &)
void showHelp(ApplicationPtr application, ArmarXDummyManagerPtr dummyManager, Options options, Ice::PropertiesPtr properties, std::ostream &out=std::cout)
Prints help according to the format selection in options.