cmdr
Artifact Content
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to tclconference@googlegroups.com
or submit via the online form by Sep 9.

Artifact 5ce1d8cd89c3360ae1263586df47817f1bb40e92:



<html><head>
<title>cmdr::ask - Cmdr, a framework for command line parsing and dispatch</title>
<style type="text/css"><!--
    HTML {
	background: 	#FFFFFF;
	color: 		black;
    }
    BODY {
	background: 	#FFFFFF;
	color:	 	black;
    }
    DIV.doctools {
	margin-left:	10%;
	margin-right:	10%;
    }
    DIV.doctools H1,DIV.doctools H2 {
	margin-left:	-5%;
    }
    H1, H2, H3, H4 {
	margin-top: 	1em;
	font-family:	sans-serif;
	font-size:	large;
	color:		#005A9C;
	background: 	transparent;
	text-align:		left;
    }
    H1.title {
	text-align: center;
    }
    UL,OL {
	margin-right: 0em;
	margin-top: 3pt;
	margin-bottom: 3pt;
    }
    UL LI {
	list-style: disc;
    }
    OL LI {
	list-style: decimal;
    }
    DT {
	padding-top: 	1ex;
    }
    UL.toc,UL.toc UL, UL.toc UL UL {
	font:		normal 12pt/14pt sans-serif;
	list-style:	none;
    }
    LI.section, LI.subsection {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding: 	0em;
    }
    PRE {
	display: 	block;
	font-family:	monospace;
	white-space:	pre;
	margin:		0%;
	padding-top:	0.5ex;
	padding-bottom:	0.5ex;
	padding-left:	1ex;
	padding-right:	1ex;
	width:		100%;
    }
    PRE.example {
	color: 		black;
	background: 	#f5dcb3;
	border:		1px solid black;
    }
    UL.requirements LI, UL.syntax LI {
	list-style: 	none;
	margin-left: 	0em;
	text-indent:	0em;
	padding:	0em;
    }
    DIV.synopsis {
	color: 		black;
	background: 	#80ffff;
	border:		1px solid black;
	font-family:	serif;
	margin-top: 	1em;
	margin-bottom: 	1em;
    }
    UL.syntax {
	margin-top: 	1em;
	border-top:	1px solid black;
    }
    UL.requirements {
	margin-bottom: 	1em;
	border-bottom:	1px solid black;
    }
--></style>
</head>
<! -- Generated from file 'cmdr_ask.man' by tcllib/doctools with format 'html'
   -->
<! -- Copyright &copy; 2013-2016 Andreas Kupries   -- Copyright &copy; 2013-2016 Documentation, Andreas Kupries
   -->
<! -- CVS: $Id$ cmdr::ask.n
   -->
<body><div class="doctools">
<hr> [
   <a href="../../../../../../home">Home</a>
| <a href="../../toc.html">Main Table Of Contents</a>
| <a href="../toc.html">Table Of Contents</a>
| <a href="../../index.html">Keyword Index</a>
 ] <hr>
<h1 class="title">cmdr::ask(n) 1 doc &quot;Cmdr, a framework for command line parsing and dispatch&quot;</h1>
<div id="name" class="section"><h2><a name="name">Name</a></h2>
<p>cmdr::ask - Cmdr - Terminal-based simple user interactions</p>
</div>
<div id="toc" class="section"><h2><a name="toc">Table Of Contents</a></h2>
<ul class="toc">
<li class="section"><a href="#toc">Table Of Contents</a></li>
<li class="section"><a href="#synopsis">Synopsis</a></li>
<li class="section"><a href="#section1">Description</a></li>
<li class="section"><a href="#section2">API</a></li>
<li class="section"><a href="#section3">Bugs, Ideas, Feedback</a></li>
<li class="section"><a href="#keywords">Keywords</a></li>
<li class="section"><a href="#copyright">Copyright</a></li>
</ul>
</div>
<div id="synopsis" class="section"><h2><a name="synopsis">Synopsis</a></h2>
<div class="synopsis">
<ul class="requirements">
<li>package require <b class="pkgname">cmdr::color</b></li>
<li>package require <b class="pkgname">linenoise</b></li>
<li>package require <b class="pkgname">struct::matrix</b></li>
<li>package require <b class="pkgname">textutil::adjust</b></li>
<li>package require <b class="pkgname">try</b></li>
<li>package require <b class="pkgname">cmdr::ask</b></li>
</ul>
<ul class="syntax">
<li><a href="#1"><b class="cmd">::cmdr::ask</b> <b class="method">string</b> <i class="arg">query</i> <span class="opt">?<i class="arg">default</i>?</span></a></li>
<li><a href="#2"><b class="cmd">::cmdr::ask</b> <b class="method">string/extended</b> <i class="arg">query</i> <span class="opt">?options...?</span></a></li>
<li><a href="#3"><b class="cmd">::cmdr::ask</b> <b class="method">string*</b> <i class="arg">query</i></a></li>
<li><a href="#4"><b class="cmd">::cmdr::ask</b> <b class="method">yn</b> <i class="arg">query</i> <span class="opt">?<i class="arg">default</i>?</span></a></li>
<li><a href="#5"><b class="cmd">::cmdr::ask</b> <b class="method">choose</b> <i class="arg">query</i> <i class="arg">choices</i> <span class="opt">?<i class="arg">default</i>?</span></a></li>
<li><a href="#6"><b class="cmd">::cmdr::ask</b> <b class="method">menu</b> <i class="arg">header</i> <i class="arg">prompt</i> <i class="arg">choices</i> <span class="opt">?<i class="arg">default</i>?</span></a></li>
</ul>
</div>
</div>
<div id="section1" class="section"><h2><a name="section1">Description</a></h2>
<p>Welcome to the Cmdr project, written by Andreas Kupries.</p>
<p>For availability please read <i class="term"><a href="cmdr_howto_get_sources.html">Cmdr - How To Get The Sources</a></i>.</p>
<p>This package provides a few utility commands implementing a few simple
terminal-based interactions with the user.</p>
</div>
<div id="section2" class="section"><h2><a name="section2">API</a></h2>
<dl class="definitions">
<dt><a name="1"><b class="cmd">::cmdr::ask</b> <b class="method">string</b> <i class="arg">query</i> <span class="opt">?<i class="arg">default</i>?</span></a></dt>
<dd><p>When invoked this command prompts the user with <i class="arg">query</i> for a string.
If the <i class="arg">default</i> is specified and not the empty string it is also
shown as part of the prompt. Note that <i class="arg">default</i> defaults to the
empty string.</p>
<p>The interactively entered string is returned as the result of the
command. The <i class="arg">default</i> is returned as the result if the user entered
an empty string and the <i class="arg">default</i> is not empty.</p>
<dl class="arguments">
<dt>string <i class="arg">query</i></dt>
<dd><p>The prompt to show to the user before interaction begins.</p></dd>
<dt>string <i class="arg">default</i></dt>
<dd><p>The default to return if the user enters nothing.</p></dd>
</dl></dd>
<dt><a name="2"><b class="cmd">::cmdr::ask</b> <b class="method">string/extended</b> <i class="arg">query</i> <span class="opt">?options...?</span></a></dt>
<dd><p>This command is similar to <b class="cmd">::cmdr::ask string</b>, except it allows for
more customization of the interaction through options.</p>
<p>The accepted options are</p>
<dl class="options">
<dt><b class="option">-history</b> boolean</dt>
<dd><p>If <b class="const">true</b>, save user input into <b class="package">linenoise</b>'s in-memory history. Default is <b class="const">false</b>.</p></dd>
<dt><b class="option">-hidden</b> boolean</dt>
<dd><p>If <b class="const">true</b>, input is hidden. Default is <b class="const">false</b>, visible echo.</p></dd>
<dt><b class="option">-complete</b> cmdprefix</dt>
<dd><p>If not empty, installed as completion callback.</p></dd>
<dt><b class="option">-default</b> string</dt>
<dd><p>If not empty the string to return if the user enters the empty string.</p></dd>
</dl>
<dl class="arguments">
<dt>string <i class="arg">query</i></dt>
<dd><p>The prompt to show to the user before interaction begins.</p></dd>
</dl></dd>
<dt><a name="3"><b class="cmd">::cmdr::ask</b> <b class="method">string*</b> <i class="arg">query</i></a></dt>
<dd><p>Behaves like <b class="cmd">::cmdr::ask string</b> without a default, except that the user's
input is not echoed back to the terminal. This command is for the entry of hidden
strings, i.e. passwords, and the like.</p>
<dl class="arguments">
<dt>string <i class="arg">query</i></dt>
<dd><p>The prompt to show to the user before interaction begins.</p></dd>
</dl></dd>
<dt><a name="4"><b class="cmd">::cmdr::ask</b> <b class="method">yn</b> <i class="arg">query</i> <span class="opt">?<i class="arg">default</i>?</span></a></dt>
<dd><p>When invoked this command prompts the user with <i class="arg">query</i> for a <em>boolean</em>
value/string. If the <i class="arg">default</i> is specified and not the empty string it is
also shown as part of the prompt. Note that <i class="arg">default</i> defaults to the empty
string.</p>
<p>The interactively entered boolean is returned as the result of the command.
The <i class="arg">default</i> boolean is returned as the result if the user entered an empty
string and the <i class="arg">default</i> is not empty.</p>
<p>Note that the command will not return until the user entered a valid
boolean value. Entering a non-boolean string causes the command to loop internally
and re-prompt.</p>
<dl class="arguments">
<dt>string <i class="arg">query</i></dt>
<dd><p>The prompt to show to the user before interaction begins.</p></dd>
<dt>string <i class="arg">default</i></dt>
<dd><p>The default boolean to return if the user enters nothing.</p></dd>
</dl></dd>
<dt><a name="5"><b class="cmd">::cmdr::ask</b> <b class="method">choose</b> <i class="arg">query</i> <i class="arg">choices</i> <span class="opt">?<i class="arg">default</i>?</span></a></dt>
<dd><p>When invoked this command prompts the user with <i class="arg">query</i> for one of the
<i class="arg">choices</i>, entered as string. Prompt and input happen on a single line.</p>
<p>The interactively entered choice is returned as the result of the command.
The <i class="arg">default</i> choice is returned as the result if the user entered an empty
string and the <i class="arg">default</i> is not empty.</p>
<p>Note that the command will not return until the user entered a valid
choice. Entering a non-choice causes the command to loop internally and re-prompt.
The user is supported in entry by an internal completion callback.</p>
<dl class="arguments">
<dt>string <i class="arg">query</i></dt>
<dd><p>The prompt to show to the user before interaction begins.</p></dd>
<dt>string <i class="arg">default</i></dt>
<dd><p>The default boolean to return if the user enters nothing.</p></dd>
</dl></dd>
<dt><a name="6"><b class="cmd">::cmdr::ask</b> <b class="method">menu</b> <i class="arg">header</i> <i class="arg">prompt</i> <i class="arg">choices</i> <span class="opt">?<i class="arg">default</i>?</span></a></dt>
<dd><p>Similar to <b class="cmd">::cmdr::ask choose</b>, except that the <i class="arg">choices</i> are shown
as an enumerated menu, one per line, with a leading <i class="arg">header</i>.
Furthermore the command accepts not only the choices as input, but also their
numeric indices in the menu. The result however is always the relevant chosen string.</p></dd>
</dl>
</div>
<div id="section3" class="section"><h2><a name="section3">Bugs, Ideas, Feedback</a></h2>
<p>Both the package(s) and this documentation will undoubtedly contain
bugs and other problems.
Please report such at
<a href="https:/core.tcl.tk/akupries/cmdr">Cmdr Tickets</a>.</p>
<p>Please also report any ideas you may have for enhancements of
either package(s) and/or documentation.</p>
</div>
<div id="keywords" class="section"><h2><a name="keywords">Keywords</a></h2>
<p><a href="../../index.html#key4">arguments</a>, <a href="../../index.html#key5">command hierarchy</a>, <a href="../../index.html#key9">command line completion</a>, <a href="../../index.html#key11">command line handling</a>, <a href="../../index.html#key13">command tree</a>, <a href="../../index.html#key0">editing command line</a>, <a href="../../index.html#key8">help for command line</a>, <a href="../../index.html#key6">hierarchy of commands</a>, <a href="../../index.html#key3">interactive command shell</a>, <a href="../../index.html#key1">optional arguments</a>, <a href="../../index.html#key2">options</a>, <a href="../../index.html#key12">parameters</a>, <a href="../../index.html#key10">processing command line</a>, <a href="../../index.html#key7">tree of commands</a></p>
</div>
<div id="copyright" class="section"><h2><a name="copyright">Copyright</a></h2>
<p>Copyright &copy; 2013-2016 Andreas Kupries<br>
Copyright &copy; 2013-2016 Documentation, Andreas Kupries</p>
</div>
</div></body></html>