<!-- clanlib header begin --> <HTML> <HEAD> <TITLE>CL_CommandLine - ClanLib Game SDK</TITLE> <STYLE TYPE="text/css"><!-- HTML BODY { font-family: verdana, helvetica, sans-serif; font-size: 12px; } H1 { font-size: 22px; } H2 { font-size: 18px; } H3 { font-size: 16px; } H4 { font-size: 14px; } P { font-size: 12px; } LI { font-size: 12px; } --></STYLE> </HEAD> <body bgcolor=white text=black link=blue vlink=#800080> <center> <img src="http://clanlib.org/gfx/clanlib.png"> </center> <!-- clanlib header end --> <center> <p> <a href="http://clanlib.org/docs.html">Home</a> | <a href="classes.html">All Classes</a> | <a href="modules.html">Grouped Classes</a> | <a href="index.html">Index</a> | <a href="search.html">Search</a> </p> </center> <h1>Class CL_CommandLine</h1> <p> Helper class to parse command line arguments <a href="#description">More...</a></p> <p>Derived from: <i>none</i> <br> Derived by: <i>none</i> <br>Group: Core (System)</p> <p> #include <ClanLib/core.h> <p> <table border=0 width=100%> </table> <p><b>Construction:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_CommandLine__CL_CommandLine.html">CL_CommandLine</a></p></td><td valign=top><p></p></td></tr></table> <p><b>Attributes:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_CommandLine__get_key.html">get_key</a></p></td><td valign=top><p> Return the key of the current option</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__get_argument.html">get_argument</a></p></td><td valign=top><p> Return the argument to the current option</p></td></tr></table> <p><b>Operations:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_CommandLine__set_help_indent.html">set_help_indent</a></p></td><td valign=top><p> Change the indention used for the help message, default is 18</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__add_usage.html">add_usage</a></p></td><td valign=top><p> Add a usage line to the help output, usage is for example "[OPTIONS]... FILE", the program name will get appended automatically</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__add_doc.html">add_doc</a></p></td><td valign=top><p> Adds extra documentation to the help output, should only be used at the beginning or at the end, to</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__add_group.html">add_group</a></p></td><td valign=top><p> Starts a new group of options, the grouptopic gets printed above the group of options in the print_help() output</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__add_option.html">add_option</a></p></td><td valign=top><p> Adds a option to the parser</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__parse_args.html">parse_args</a></p></td><td valign=top><p> Parse the options arcording to the options added with add_option(), result of the parsing is accessible via next() and get_key()/get_argument()</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__print_help.html">print_help</a></p></td><td valign=top><p> Print the help output, normaly done via a --help option</p></td></tr><tr><td width=30% valign=top><p><a href="CL_CommandLine__next.html">next</a></p></td><td valign=top><p> Goto the next option</p></td></tr></table> <a name="#description"><p><b>Detailed description:</b></p> !group=Core/System! !header=core.h! <p>The CL_CommandLine class helps to parse command line arguments, namely the argc/argv pair that you get from main(). CL_CommandLine mimics getopt_long() behaviour as closely as possible, while providing a cleaner interface and a few additional features, like automatic generation of '--help' output. CL_CommandLine can parse long arguments in the following styles:</p> <p>program --file FILENAME<br> program --file=FILENAME</p> <p>Short arguments are handled like this:</p> <p>program -f FILENAME</p> <p>Concatenating short arguments is also supported, so that:</p> <p>program -f -a -b FILENAME</p> <p>is equivalent to:</p> <p>program -fab FILENAME</p> <p>Non-option arguments (aka rest arguments) are supported as well:</p> <p>program SOMEFILE SOMEOTHERFILE ...</p> <p>To avoid ambiguity when a filename starts with '-' CL_CommandLine stops parsing arguments after the first encounter of a '--', so in</p> <p>program -f -b -- -f -b</p> <p>In the above example the first '-f -b' options are treated as normal while the ones after the '--' are treated as rest arguments (aka filenames in most programs).</p> <!-- clanlib footer begin --> <center><br><br><font color="#a0a0a0"> Questions or comments, write to the <a href="http://clanlib.org/contact.html">ClanLib mailing list</a>. </font></center> </body> </html> <!-- clanlib footer end -->