<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="rustdoc">
<title>Docs</title>
</head>
<body class="rustdoc">
<h1 class="title">Docs</h1>
<nav id="TOC"><ul>
<li><a href="#optparse">1 optparse</a><ul>
<li><a href="#table-of-contents">1.1 Table of Contents</a><ul></ul></li>
<li><a href="#license">1.2 License</a><ul></ul></li>
<li><a href="#installation">1.3 Installation</a><ul></ul></li>
<li><a href="#documentation">1.4 Documentation</a><ul></ul></li>
<li><a href="#usage">1.5 Usage</a><ul></ul></li>
<li><a href="#work-in-progress">1.6 Work in Progress</a><ul></ul></li></ul></li></ul></nav><h1 id="optparse" class="section-header"><a href="#optparse">1 optparse</a></h1>
<p><img src="https://img.shields.io/github/downloads/atom/atom/total.svg" alt="downloads" />
<img src="https://img.shields.io/appveyor/ci/rootlou/optparse" alt="build" /></p>
<h2 id="table-of-contents" class="section-header"><a href="#table-of-contents">1.1 Table of Contents</a></h2>
<p>[TOC]</p>
<h2 id="license" class="section-header"><a href="#license">1.2 License</a></h2>
<p>This project is licensed under <a href="https://www.gnu.org/licenses/gpl-3.0.html">GPLv3</a>.</p>
<h2 id="installation" class="section-header"><a href="#installation">1.3 Installation</a></h2>
<p>To add optparse to you Project by downloading it from <a href="https://crates.io/crates/optparse">crates.io</a> or simply add it to your dependencies:</p>
<pre><code class="language-toml">[dependencies]
optparse = ["0.1.0"]
</code></pre>
<h2 id="documentation" class="section-header"><a href="#documentation">1.4 Documentation</a></h2>
<p>The documentation can be found </p>
<h2 id="usage" class="section-header"><a href="#usage">1.5 Usage</a></h2>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="comment">// import the crate</span>
<span class="kw">use</span> <span class="ident">optparse</span>;
<span class="comment">// functions/closures must take String as their only parameter</span>
<span class="comment">// and not return anything</span>
<span class="kw">fn</span> <span class="ident">hello</span>(<span class="ident">arg</span>: <span class="ident">String</span>) {
<span class="macro">println</span><span class="macro">!</span>(<span class="string">"Hello {} \o/"</span>, <span class="ident">arg</span>);
}
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="comment">// create a new parser with a parser description</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">parser</span> <span class="op">=</span> <span class="ident">optargs</span>::<span class="ident">Parser</span>::<span class="ident">new</span>(<span class="string">"Example Description"</span>);
<span class="comment">// register a flag and a corresponding function to be called</span>
<span class="comment">// from the command line</span>
<span class="comment">// register!(flag, command description, function/closure, parser);</span>
<span class="macro">register</span><span class="macro">!</span>(<span class="string">"-welcome"</span>, <span class="string">"Example Description"</span>, <span class="ident">hello</span>, <span class="ident">parser</span>);
<span class="comment">// run the parser using the arguments from std::env</span>
<span class="comment">// parse!(arguments, arguments length, parser)</span>
<span class="kw">let</span> <span class="ident">args</span> <span class="op">=</span> <span class="ident">std</span>::<span class="ident">env</span>::<span class="ident">args</span>().<span class="ident">collect</span>();
<span class="macro">parse</span><span class="macro">!</span>(<span class="ident">args</span>.<span class="ident">clone</span>(), <span class="ident">args</span>.<span class="ident">len</span>() <span class="kw">as</span> <span class="ident">u8</span>, <span class="ident">parser</span>);
}</pre></div>
<h2 id="work-in-progress" class="section-header"><a href="#work-in-progress">1.6 Work in Progress</a></h2>
<ul>
<li>[ ] aliasing</li>
<li>[ ] single flag parsing</li>
<li>[ ] multi parameter closures</li>
</ul>
<p>:::info
<strong>You want to contribute?</strong> Feel free to leave a comment or create a pull request.
:::</p>
</body>
</html>