Files
cligen/docs/CliGen/Arg.html
2026-08-09 15:20:06 -05:00

451 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Crystal Docs 1.20.3">
<meta name="crystal_docs.project_version" content="object_rework-dev">
<meta name="crystal_docs.project_name" content="CliGenerator">
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/doc.js"></script>
<meta name="repository-name" content="CliGenerator">
<title>CliGen::Arg - CliGenerator object_rework-dev</title>
<script type="text/javascript">
CrystalDocs.base_path = "../";
</script>
</head>
<body>
<svg class="hidden">
<symbol id="octicon-link" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path>
</symbol>
</svg>
<input type="checkbox" id="sidebar-btn">
<label for="sidebar-btn" id="sidebar-btn-label">
<svg class="open" xmlns="http://www.w3.org/2000/svg" height="2em" width="2em" viewBox="0 0 512 512"><title>Open Sidebar</title><path fill="currentColor" d="M80 96v64h352V96H80zm0 112v64h352v-64H80zm0 112v64h352v-64H80z"></path></svg>
<svg class="close" xmlns="http://www.w3.org/2000/svg" width="2em" height="2em" viewBox="0 0 512 512"><title>Close Sidebar</title><path fill="currentColor" d="m118.6 73.4-45.2 45.2L210.7 256 73.4 393.4l45.2 45.2L256 301.3l137.4 137.3 45.2-45.2L301.3 256l137.3-137.4-45.2-45.2L256 210.7Z"></path></svg>
</label>
<div class="sidebar">
<div class="sidebar-header">
<div class="search-box">
<input type="search" class="search-input" placeholder="Search..." spellcheck="false" aria-label="Search">
</div>
<div class="project-summary">
<h1 class="project-name">
<a href="../index.html">
CliGenerator
</a>
</h1>
<span class="project-version">
object_rework-dev
</span>
</div>
</div>
<div class="search-results hidden">
<ul class="search-list"></ul>
</div>
<div class="types-list">
<ul>
<li class="parent open current" data-id="CliGenerator/CliGen" data-name="cligen">
<a href="../CliGen.html">CliGen</a>
<ul>
<li class=" " data-id="CliGenerator/CliGen/AdditionalDefaultFlag" data-name="cligen::additionaldefaultflag">
<a href="../CliGen/AdditionalDefaultFlag.html">AdditionalDefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/App" data-name="cligen::app">
<a href="../CliGen/App.html">App</a>
</li>
<li class=" current" data-id="CliGenerator/CliGen/Arg" data-name="cligen::arg">
<a href="../CliGen/Arg.html">Arg</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Argument" data-name="cligen::argument">
<a href="../CliGen/Argument.html">Argument</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/BaseFlag" data-name="cligen::baseflag">
<a href="../CliGen/BaseFlag.html">BaseFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Command" data-name="cligen::command">
<a href="../CliGen/Command.html">Command</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandInfo" data-name="cligen::commandinfo">
<a href="../CliGen/CommandInfo.html">CommandInfo</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/CommandNode" data-name="cligen::commandnode">
<a href="../CliGen/CommandNode.html">CommandNode</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/DefaultFlag" data-name="cligen::defaultflag">
<a href="../CliGen/DefaultFlag.html">DefaultFlag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Flag" data-name="cligen::flag(t)">
<a href="../CliGen/Flag.html">Flag</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Format" data-name="cligen::format">
<a href="../CliGen/Format.html">Format</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/MatchType" data-name="cligen::matchtype">
<a href="../CliGen/MatchType.html">MatchType</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/ProxyCommand" data-name="cligen::proxycommand">
<a href="../CliGen/ProxyCommand.html">ProxyCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Regex" data-name="cligen::regex">
<a href="../CliGen/Regex.html">Regex</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Selection" data-name="cligen::selection">
<a href="../CliGen/Selection.html">Selection</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/SubCommand" data-name="cligen::subcommand">
<a href="../CliGen/SubCommand.html">SubCommand</a>
</li>
<li class=" " data-id="CliGenerator/CliGen/Trigger" data-name="cligen::trigger">
<a href="../CliGen/Trigger.html">Trigger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="main-content">
<h1 class="type-name">
<span class="kind">
class
</span> CliGen::<wbr>Arg
</h1>
<ul class="superclass-hierarchy"><li class="superclass"><a href="../CliGen/Arg.html">CliGen::Arg</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
<h2>
<a id="overview" class="anchor" href="#overview">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Overview
</h2>
<p>This class serves as a &quot;argument wrapper&quot; to force a fail-fast approach to
arg-parsing.</p>
<p>It wraps around the argument + index of the argument to do state tracking
and ensure that each argument is only processed once (plus allows for
easier filtering of processed arguments to avoid having to do index math)</p>
<pre><code class="language-crystal">args.reject(<span class="o">&amp;</span>.processed?) <span class="c"># returns the args that haven&#39;t been processed yet</span></code></pre>
<p>It expects each argument to only be processed once and will force a raise
if the argument has Arg#processed called a second time. This is to force
the developer (me) to fix any processing issues during the development of
this framework.</p>
<h2>
<a id="defined-in" class="anchor" href="#defined-in">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Defined in:
</h2>
cligen/arg.cr
<br/>
<h2>
<a id="constructors" class="anchor" href="#constructors">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructors
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new%28value%3AString%2Cindex%3AInt32%29-class-method" class="signature"><strong>.new</strong>(value : String, index : Int32)</a>
</li>
</ul>
<h2>
<a id="instance-method-summary" class="anchor" href="#instance-method-summary">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Summary
</h2>
<ul class="list-summary">
<li class="entry-summary">
<a href="#index%3AInt32-instance-method" class="signature"><strong>#index</strong> : Int32</a>
<div class="summary"><p>The index of the argument in the array it was in</p></div>
</li>
<li class="entry-summary">
<a href="#processed-instance-method" class="signature"><strong>#processed</strong></a>
<div class="summary"><p>This serves as a trigger that tells the object that it has been processed</p></div>
</li>
<li class="entry-summary">
<a href="#processed%3F%3ABool-instance-method" class="signature"><strong>#processed?</strong> : Bool</a>
<div class="summary"><p>The &quot;flag&quot;/variable that tracks is the Arg has been processed yet</p></div>
</li>
<li class="entry-summary">
<a href="#value%3AString-instance-method" class="signature"><strong>#value</strong> : String</a>
<div class="summary"><p>The raw string argument provided from the user</p></div>
</li>
</ul>
<div class="methods-inherited">
</div>
<h2>
<a id="constructor-detail" class="anchor" href="#constructor-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Constructor Detail
</h2>
<div class="entry-detail" id="new(value:String,index:Int32)-class-method">
<div class="signature">
def self.<strong>new</strong>(value : String, index : Int32)
<a class="method-permalink" href="#new%28value%3AString%2Cindex%3AInt32%29-class-method">#</a>
</div>
<br/>
<div>
</div>
</div>
<h2>
<a id="instance-method-detail" class="anchor" href="#instance-method-detail">
<svg class="octicon-link" aria-hidden="true">
<use href="#octicon-link"/>
</svg>
</a>
Instance Method Detail
</h2>
<div class="entry-detail" id="index:Int32-instance-method">
<div class="signature">
def <strong>index</strong> : Int32
<a class="method-permalink" href="#index%3AInt32-instance-method">#</a>
</div>
<div class="doc">
<p>The index of the argument in the array it was in</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="processed-instance-method">
<div class="signature">
def <strong>processed</strong>
<a class="method-permalink" href="#processed-instance-method">#</a>
</div>
<div class="doc">
<p>This serves as a trigger that tells the object that it has been processed</p>
<p>This will raise an exception if it is re-called after already having been
processed.</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="processed?:Bool-instance-method">
<div class="signature">
def <strong>processed?</strong> : Bool
<a class="method-permalink" href="#processed%3F%3ABool-instance-method">#</a>
</div>
<div class="doc">
<p>The &quot;flag&quot;/variable that tracks is the Arg has been processed yet</p>
</div>
<br/>
<div>
</div>
</div>
<div class="entry-detail" id="value:String-instance-method">
<div class="signature">
def <strong>value</strong> : String
<a class="method-permalink" href="#value%3AString-instance-method">#</a>
</div>
<div class="doc">
<p>The raw string argument provided from the user</p>
</div>
<br/>
<div>
</div>
</div>
</div>
</body>
</html>