adopt/reference/index.html @ 15305ac3db17
adopt: Update site.
author |
Steve Losh <steve@stevelosh.com> |
date |
Thu, 22 Nov 2018 00:39:35 -0500 |
parents |
(none) |
children |
bcc463ff154f |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title> API Reference / Adopt</title>
<link rel="stylesheet" href="../_dmedia/tango.css"/>
<link rel="stylesheet/less" type="text/css" href="../_dmedia/style.less"/>
<script src="../_dmedia/less.js" type="text/javascript">
</script>
</head>
<body class="content">
<div class="wrap">
<header><h1><a href="..">Adopt</a></h1></header>
<div class="markdown">
<h1 id="api-reference"><a href="">API Reference</a></h1><p>The following is a list of all user-facing parts of adopt.</p>
<p>If there are backwards-incompatible changes to anything listed here, they will
be noted in the changelog and the author will feel bad.</p>
<p>Anything not listed here is subject to change at any time with no warning, so
don't touch it.</p>
<div class="toc">
<ul>
<li><a href="#package-adopt">Package ADOPT</a><ul>
<li><a href="#append1-function">APPEND1 (function)</a></li>
<li><a href="#argv-function">ARGV (function)</a></li>
<li><a href="#define-interface-macro">DEFINE-INTERFACE (macro)</a></li>
<li><a href="#latest-function">LATEST (function)</a></li>
<li><a href="#parse-options-function">PARSE-OPTIONS (function)</a></li>
<li><a href="#print-usage-function">PRINT-USAGE (function)</a></li>
</ul>
</li>
</ul></div>
<h2 id="package-adopt">Package <code>ADOPT</code></h2>
<h3 id="append1-function"><code>APPEND1</code> (function)</h3>
<div class="codehilite"><pre><span/>(APPEND1 LIST EL)
</pre></div>
<p>Append element <code>el</code> to the end of <code>list</code>.</p>
<p>This is implemented as <code>(append list (list el))</code>. It is not particularly
fast.</p>
<p>It is useful as a <code>:reduce</code> function when you want to collect all values given
for an option.</p>
<h3 id="argv-function"><code>ARGV</code> (function)</h3>
<div class="codehilite"><pre><span/>(ARGV)
</pre></div>
<p>Return a list of the program name and command line arguments.</p>
<p>This is not implemented for every Common Lisp implementation. You can always
pass your own values to <code>parse-options</code> and <code>print-usage</code> if it's not
implemented for your particular Lisp.</p>
<h3 id="define-interface-macro"><code>DEFINE-INTERFACE</code> (macro)</h3>
<div class="codehilite"><pre><span/>(DEFINE-INTERFACE NAME USAGE &amp;REST OPTIONS)
</pre></div>
<h3 id="latest-function"><code>LATEST</code> (function)</h3>
<div class="codehilite"><pre><span/>(LATEST OLD NEW)
</pre></div>
<p>Return <code>new</code>.</p>
<p>It is useful as a <code>:reduce</code> function when you want to just keep the last-given
value for an option.</p>
<h3 id="parse-options-function"><code>PARSE-OPTIONS</code> (function)</h3>
<div class="codehilite"><pre><span/>(PARSE-OPTIONS INTERFACE &amp;OPTIONAL (ARGUMENTS (REST (ARGV))))
</pre></div>
<p>Parse <code>arguments</code> according to <code>interface</code>.</p>
<p>Two values are returned:</p>
<ol>
<li>A fresh list of top-level, unaccounted-for arguments that don't correspond
to any options defined in <code>interface</code>.</li>
<li>An <code>EQL</code> hash map of option <code>name</code>s to values.</li>
</ol>
<p>See the full usage documentation for more information.</p>
<h3 id="print-usage-function"><code>PRINT-USAGE</code> (function)</h3>
<div class="codehilite"><pre><span/>(PRINT-USAGE INTERFACE &amp;KEY (STREAM *STANDARD-OUTPUT*) (PROGRAM-NAME (FIRST (ARGV))) (WIDTH 80) (OPTION-WIDTH 20))
</pre></div>
<p>Print a pretty usage document for <code>interface</code> to <code>stream</code>.</p>
<p><code>width</code> should be the total width (in characters) for line-wrapping purposes.
Care will be taken to ensure lines are no longer than this, though some edge
cases (extremely long short/long option names and parameters) may slip
through.</p>
<p><code>option-width</code> should be the width of the column of short/long options (in
characters). If the short/long option documentation is shorter than this, the
option's documentation string will start on the same line. Otherwise the
option's documentation string will start on the next line.</p>
<p>The result will look something like (assuming a usage string of
<code>"[options] FILES"</code>):</p>
<div class="codehilite"><pre><span/>(print-usage *program-interface* :width 60 :option-width 15)
; =&gt;
; USAGE: /bin/foo [options] FILES
;
; Options:
; -v, --verbose Output extra information.
; -q, --quiet Shut up.
; --ignore FILE Ignore FILE. May be specified multiple
; times.
; -n NAME, --name NAME
; Your name. May be specified many times,
; last one wins.
; -m, --meow Meow.
; 0.........1.... option-width
; 0........1.........2.........3.........4.........5.........6
</pre></div>
</div>
<footer><p><i>Made with Lisp and love by <a href="http://stevelosh.com/">Steve Losh</a> in Rochester, New York.</i></p>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-15328874-3', 'auto');
ga('send', 'pageview');
</script></footer>
</div>
</body>
</html>