CINXE.COM
Term::UI - Term::ReadLine UI made easy - metacpan.org
<!DOCTYPE html> <html lang="en-US"> <head> <title>Term::UI - Term::ReadLine UI made easy - metacpan.org</title> <link rel="preload" as="fetch" href="/account/login_status" crossorigin="anonymous" /> <link href="/assets/style-XFEQ536G.css" rel="stylesheet" type="text/css"> <script src="/assets/main-WXBSEDQJ.js" type="module"></script> <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Term-UI - MetaCPAN" href="/dist/Term-UI/releases.rss" /> <link rel="canonical" href="https://metacpan.org/pod/Term::UI" /> <meta name="description" content="Term::ReadLine UI made easy" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5"> <link rel="shortcut icon" href="/static/icons/favicon.ico"> <link rel="apple-touch-icon" sizes="152x152" href="/static/icons/apple-touch-icon.png"> <link rel="search" href="/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN"> <script async src="https://perl-ads.perlhacks.com/perl-ads.js"></script> <script async src="https://www.googletagmanager.com/gtag/js?id=G-E82Q2V8LVD"></script> <meta property="og:site_name" content="MetaCPAN" /> <meta name="twitter:site" content="@metacpan" /> <meta property="og:type" content="article" /> <meta name="twitter:card" content="summary" /> <meta property="og:url" content="https://metacpan.org/pod/Term::UI" /> <meta property="og:title" content="Term::UI" /> <meta property="og:description" content="Term::ReadLine UI made easy" /> <meta property="og:image" content="https://metacpan.org/static/images/dots.png" /> </head> <body> <nav class="navbar navbar-default" role="navigation"> <div class="header-logo-large hidden-xs"> <a href="/" tabindex="0"> <svg class="logo" aria-label="MetaCPAN"> <use class="logo" href="/static/images/metacpan-logo.svg#logo" /> </svg> </a> </div> <div class="header-logo-icon visible-xs"> <a href="/"> <svg class="logo" aria-label="MetaCPAN"> <use class="logo" href="/static/images/metacpan-logo.svg#dots" /> </svg> </a> </div> <ul class="nav navbar-nav menu-items hidden-xs hidden-sm"> <li><a href="/about">About</a></li> <li><a href="/about/sponsors">Sponsor</a></li> <li><a href="https://grep.metacpan.org/">grep::cpan</a></li> <li><a href="/recent">Recent</a></li> <li><a href="/about/faq">FAQ</a></li> <li><a href="/tools">Tools</a></li> <li><a href="https://fastapi.metacpan.org/">API</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <button type="button" class="searchbar-btn visible-xs visible-sm"> <i class="fa fa-search button-fa-icon"></i> </button> <form action="/search" class="searchbar-form visible-md visible-lg search-form form-horizontal"> <input type="hidden" name="size" id="metacpan_search-size" value="20"> <div class="form-group"> <div class="search-group"> <i class="fa fa-search"></i> <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value=""> </div> </div> </form> <li class="icon-slidepanel visible-xs visible-sm"> <button data-toggle="slidepanel" data-target=".slidepanel"> <span class="button-fa-icon"> <i class="fa fa-bars slidepanel-open"></i> <i class="fa fa-times slidepanel-close"></i> </span> </button> </li> <li class="dropdown login-dropdown show-logged-in"> <button type="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i> <i class="fas fa-chevron-down"></i> </button> <ul class="dropdown-menu"> <li><a href="/account/identities">Identities</a></li> <li><a href="/account/profile">Profile</a></li> <li><a href="/account/favorite/list">Favorites</a></li> <li> <a href="#" type="button" class="logout-button"> Logout </a> </li> </ul> </li> <li class="dropdown login-dropdown show-logged-out"> <button type="button" class="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user button-fa-icon avatar-placeholder" aria-hidden="true"></i> <i class="fas fa-chevron-down"></i> </button> <ul class="dropdown-menu"> <li> <a href="/login/github"> <i class="fab fa-github fa-fw"></i> GitHub </a> </li> <li> <a href="/login/twitter"> <i class="fab fa-twitter fa-fw"></i> Twitter </a> </li> <li> <a href="/login/google"> <i class="fab fa-google fa-fw"></i> Google </a> </li> </ul> </li> <li class="dropdown login-dropdown hide-logged-in hide-logged-out"> <button> <i class="fa fa-user button-fa-icon" aria-hidden="true"></i> </button> </li> </ul> </nav> <div class="page-content "> <div id="perl-ad-target" class="top-notify-banner perl-ad-target"> </div> <nav class="sidebar"> <div class="slidepanel"> <ul class="nav-list "> <li class="nav-header no-margin-top"> <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Term-UI was released."> <span class="relatize">06 Aug 2021 16:55:59 UTC</span> </div> </li> <li> Distribution: <a href="/dist/Term-UI">Term-UI</a> </li> <li> Module version: 0.50 </li> <li> <a data-keyboard-shortcut="g s" href="/dist/Term-UI/source/lib/Term/UI.pm">Source</a> (<a href="/dist/Term-UI/source/lib/Term/UI.pm?raw=1">raw</a>) </li> <li> <a data-keyboard-shortcut="g b" href="/dist/Term-UI/source/lib/Term">Browse</a> (<a href="/dist/Term-UI/source/lib/Term?raw=1">raw</a>) </li> <li> <a data-keyboard-shortcut="g c" href="/dist/Term-UI/changes">Changes</a> </li> <li> <a class="nopopup" href="/dist/Term-UI/contribute">How to Contribute</a> </li> <li> <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/jib/term-ui">Repository</a> </li> <li> <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Term-UI">Issues</a> (6) </li> <li> <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Term-UI+0.50" title="Matrix">Testers</a> <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Term-UI.html?oncpan=1&distmat=1&version=0.50&grade=2" style="color: #090">1337</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Term-UI.html?oncpan=1&distmat=1&version=0.50&grade=3" style="color: #900">4</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Term-UI.html?oncpan=1&distmat=1&version=0.50&grade=4">0</a>)</span> </li> <li> <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/BINGOS/Term-UI-0.50">Kwalitee</a> </li> <li> <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Term-UI who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)"> Bus factor: 1 </div> </li> <li> <a rel="noopener nofollow" href="http://cpancover.com/latest/Term-UI-0.50/index.html">22.29% Coverage </a> </li> <li> License: perl_5 </li> <li class="nav-header">Activity</li> <li> <div class="activity-graph"> <img src="/dist/Term-UI/activity.svg?res=month" /> <div class="comment">24 month</div> </div> </li> <li class="nav-header">Tools</li> <li> <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/B/BI/BINGOS/Term-UI-0.50.tar.gz"> Download (<span itemprop="fileSize">13.05KB</span>)</a> </li> <li> <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FBINGOS%2FTerm-UI-0.50%2Flib%2FTerm%2FUI.pm"> MetaCPAN Explorer </a> </li> <li> <a href="/dist/Term-UI/permissions"> Permissions </a> </li> <li> <a href="/dist/Term-UI/releases.rss"> Subscribe to distribution </a> </li> <li> <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog"> Install Instructions </button> </li> <li> <form action="/search"> <input type="hidden" name="q" value="dist:Term-UI"> <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form"> <input type="submit" style="display: none"> </form> </li> <li> <form action="https://grep.metacpan.org/search"> <input type="hidden" name="qd" value="Term-UI"> <input type="hidden" name="source" value="metacpan"> <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form"> <input type="submit" style="display: none"> </form> </li> <li class="version-jump"> <select class="select-navigator form-control tool-bar-form"> <option disabled selected>Jump to version</option> <option disabled value="/release/BINGOS/Term-UI-0.50/view/lib/Term/UI.pm" >0.50 (BINGOS on 2021-08-06)</option> <option value="/release/BINGOS/Term-UI-0.48/view/lib/Term/UI.pm" >0.48 (BINGOS on 2021-08-03)</option> <option value="/release/BINGOS/Term-UI-0.46/view/lib/Term/UI.pm" >0.46 (BINGOS on 2015-05-25)</option> <option value="/release/KANE/Term-UI-0.20/view/lib/Term/UI.pm" >0.20 (KANE on 2009-04-24)</option> <option value="/release/KANE/Term-UI-0.18/view/lib/Term/UI.pm" >0.18 (KANE on 2007-11-04)</option> <option value="/release/KANE/Term-UI-0.16/view/lib/Term/UI.pm" >0.16 (KANE on 2007-10-03)</option> <option value="/release/KANE/Term-UI-0.14/view/lib/Term/UI.pm" >0.14 (KANE on 2006-10-23)</option> <option value="/release/KANE/Term-UI-0.12/view/lib/Term/UI.pm" >0.12 (KANE on 2005-08-25)</option> <option value="/release/KANE/Term-UI-0.11/view/lib/Term/UI.pm" >0.11 (KANE on 2005-08-24)</option> <option value="/release/KANE/Term-UI-0.05/view/lib/Term/UI.pm" >0.05 (KANE on 2005-01-13)</option> <option value="/release/KANE/Term-UI-0.04/view/lib/Term/UI.pm" >0.04 (KANE on 2004-12-03)</option> <option value="/release/KANE/Term-UI-0.03/view/lib/Term/UI.pm" >0.03 (KANE on 2003-10-05)</option> <option value="/release/KANE/Term-UI-0.02/view/lib/Term/UI.pm" >0.02 (KANE on 2003-05-10)</option> <optgroup label="BackPAN">' <option value="/release/BINGOS/Term-UI-0.44/view/lib/Term/UI.pm" >0.44 (BINGOS on 2015-05-25)</option> <option value="/release/BINGOS/Term-UI-0.42/view/lib/Term/UI.pm" >0.42 (BINGOS on 2014-01-02)</option> <option value="/release/BINGOS/Term-UI-0.40/view/lib/Term/UI.pm" >0.40 (BINGOS on 2014-01-01)</option> <option value="/release/BINGOS/Term-UI-0.38/view/lib/Term/UI.pm" >0.38 (BINGOS on 2013-09-23)</option> <option value="/release/BINGOS/Term-UI-0.36/view/lib/Term/UI.pm" >0.36 (BINGOS on 2013-06-05)</option> <option value="/release/BINGOS/Term-UI-0.34/view/lib/Term/UI.pm" >0.34 (BINGOS on 2013-01-22)</option> <option value="/release/BINGOS/Term-UI-0.32/view/lib/Term/UI.pm" >0.32 (BINGOS on 2012-11-10)</option> <option value="/release/BINGOS/Term-UI-0.30/view/lib/Term/UI.pm" >0.30 (BINGOS on 2011-12-21)</option> <option value="/release/BINGOS/Term-UI-0.28/view/lib/Term/UI.pm" >0.28 (BINGOS on 2011-12-21)</option> <option value="/release/BINGOS/Term-UI-0.26/view/lib/Term/UI.pm" >0.26 (BINGOS on 2011-02-09)</option> <option value="/release/BINGOS/Term-UI-0.24/view/lib/Term/UI.pm" >0.24 (BINGOS on 2011-01-12)</option> <option value="/release/BINGOS/Term-UI-0.22/view/lib/Term/UI.pm" >0.22 (BINGOS on 2011-01-07)</option> </optgroup> </select> </li> <li class="version-diff"> <select class="select-navigator form-control tool-bar-form"> <option disabled selected>Diff with version</option> <option disabled value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.50/lib/Term/UI.pm" >0.50 (BINGOS on 2021-08-06)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.48/lib/Term/UI.pm" >0.48 (BINGOS on 2021-08-03)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.46/lib/Term/UI.pm" >0.46 (BINGOS on 2015-05-25)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.20/lib/Term/UI.pm" >0.20 (KANE on 2009-04-24)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.18/lib/Term/UI.pm" >0.18 (KANE on 2007-11-04)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.16/lib/Term/UI.pm" >0.16 (KANE on 2007-10-03)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.14/lib/Term/UI.pm" >0.14 (KANE on 2006-10-23)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.12/lib/Term/UI.pm" >0.12 (KANE on 2005-08-25)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.11/lib/Term/UI.pm" >0.11 (KANE on 2005-08-24)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.05/lib/Term/UI.pm" >0.05 (KANE on 2005-01-13)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.04/lib/Term/UI.pm" >0.04 (KANE on 2004-12-03)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.03/lib/Term/UI.pm" >0.03 (KANE on 2003-10-05)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/KANE/Term-UI-0.02/lib/Term/UI.pm" >0.02 (KANE on 2003-05-10)</option> <optgroup label="BackPAN">' <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.44/lib/Term/UI.pm" >0.44 (BINGOS on 2015-05-25)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.42/lib/Term/UI.pm" >0.42 (BINGOS on 2014-01-02)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.40/lib/Term/UI.pm" >0.40 (BINGOS on 2014-01-01)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.38/lib/Term/UI.pm" >0.38 (BINGOS on 2013-09-23)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.36/lib/Term/UI.pm" >0.36 (BINGOS on 2013-06-05)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.34/lib/Term/UI.pm" >0.34 (BINGOS on 2013-01-22)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.32/lib/Term/UI.pm" >0.32 (BINGOS on 2012-11-10)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.30/lib/Term/UI.pm" >0.30 (BINGOS on 2011-12-21)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.28/lib/Term/UI.pm" >0.28 (BINGOS on 2011-12-21)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.26/lib/Term/UI.pm" >0.26 (BINGOS on 2011-02-09)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.24/lib/Term/UI.pm" >0.24 (BINGOS on 2011-01-12)</option> <option value="/release/BINGOS/Term-UI-0.50/diff/BINGOS/Term-UI-0.22/lib/Term/UI.pm" >0.22 (BINGOS on 2011-01-07)</option> </optgroup> </select> </li> <li> <ul class="dependencies"> <li class="nav-header">Dependencies</li> <li><a href="/pod/Locale::Maketext::Simple" title="Locale::Maketext::Simple" class="ellipsis">Locale::Maketext::Simple</a></li> <li><a href="/pod/Log::Message::Simple" title="Log::Message::Simple" class="ellipsis">Log::Message::Simple</a></li> <li><a href="/pod/Params::Check" title="Params::Check" class="ellipsis">Params::Check</a></li> <li><a href="/pod/Term::ReadLine" title="Term::ReadLine" class="ellipsis">Term::ReadLine</a></li> <li><a href="/pod/Test::More" title="Test::More" class="ellipsis">Test::More</a></li> <li><a href="/pod/if" title="if" class="ellipsis">if</a></li> <li><a href="/pod/parent" title="parent" class="ellipsis">parent</a></li> <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li> <li> <hr> </li> <li> <a href="/module/Term::UI/requires">Reverse dependencies</a> </li> <li> <a href="http://deps.cpantesters.org/?module=Term%3A%3AUI">CPAN Testers List</a> </li> <li> <a href="https://cpandeps.grinnz.com/?dist=Term-UI">Dependency graph</a> </li> </ul> </li> <li class="nav-header">Permalinks</li> <li> <a href="/release/BINGOS/Term-UI-0.50/view/lib/Term/UI.pm">This version</a> </li> <li> <a href="/pod/Term::UI">Latest version</a> </li> <li> <div class="plussers"> <div class="nav-header">++ed by:</div> <div> <a class="display-all" href="/author/PWBENNETT"><img src="https://www.gravatar.com/avatar/41a085cce4a7061cf4ee49d02b9bed0e?d=identicon&s=20" title="PWBENNETT" alt="PWBENNETT"></a> <a class="display-all" href="/author/GETTY"><img src="https://www.gravatar.com/avatar/d374f794bb2f39232c29d0b376b9dcc4?d=identicon&s=20" title="GETTY" alt="GETTY"></a> <a class="display-all" href="/author/KEEDI"><img src="https://www.gravatar.com/avatar/95f905a7a4ccc573c711e9d264c0fde8?d=identicon&s=20" title="KEEDI" alt="KEEDI"></a> </div> <!-- Display counts of plussers--> <div> <a href="/dist/Term-UI/plussers">3 PAUSE users</a> </div> <div> 2 non-PAUSE users </div> </div> </li> <li> <div> <button class="contributors-show-button btn-link">and 1 contributors</button> <div id="metacpan_contributors" class="slide-out slide-out-hidden"> <div> <ul> <li class="contributor" > Jos Boumans <kane[at]cpan.org> </li> </ul> </div> </div> </div> </li> </ul> </div> </nav> <div class="content-navigation"> <div class="breadcrumbs"> <span> <a data-keyboard-shortcut="g a" rel="author" href="/author/BINGOS" class="author-name">Chris Williams</a> </span> <span> / </span> <div class="release dist-release status-latest maturity-released"> <span class="dropdown"><b class="caret"></b></span> <select class="select-navigator "> <option selected value="/release/BINGOS/Term-UI-0.50/view/lib/Term/UI.pm" >0.50 (BINGOS on 2021-08-06)</option> <option value="/release/BINGOS/Term-UI-0.48/view/lib/Term/UI.pm" >0.48 (BINGOS on 2021-08-03)</option> <option value="/release/BINGOS/Term-UI-0.46/view/lib/Term/UI.pm" >0.46 (BINGOS on 2015-05-25)</option> <option value="/release/KANE/Term-UI-0.20/view/lib/Term/UI.pm" >0.20 (KANE on 2009-04-24)</option> <option value="/release/KANE/Term-UI-0.18/view/lib/Term/UI.pm" >0.18 (KANE on 2007-11-04)</option> <option value="/release/KANE/Term-UI-0.16/view/lib/Term/UI.pm" >0.16 (KANE on 2007-10-03)</option> <option value="/release/KANE/Term-UI-0.14/view/lib/Term/UI.pm" >0.14 (KANE on 2006-10-23)</option> <option value="/release/KANE/Term-UI-0.12/view/lib/Term/UI.pm" >0.12 (KANE on 2005-08-25)</option> <option value="/release/KANE/Term-UI-0.11/view/lib/Term/UI.pm" >0.11 (KANE on 2005-08-24)</option> <option value="/release/KANE/Term-UI-0.05/view/lib/Term/UI.pm" >0.05 (KANE on 2005-01-13)</option> <option value="/release/KANE/Term-UI-0.04/view/lib/Term/UI.pm" >0.04 (KANE on 2004-12-03)</option> <option value="/release/KANE/Term-UI-0.03/view/lib/Term/UI.pm" >0.03 (KANE on 2003-10-05)</option> <option value="/release/KANE/Term-UI-0.02/view/lib/Term/UI.pm" >0.02 (KANE on 2003-05-10)</option> <optgroup label="BackPAN">' <option value="/release/BINGOS/Term-UI-0.44/view/lib/Term/UI.pm" >0.44 (BINGOS on 2015-05-25)</option> <option value="/release/BINGOS/Term-UI-0.42/view/lib/Term/UI.pm" >0.42 (BINGOS on 2014-01-02)</option> <option value="/release/BINGOS/Term-UI-0.40/view/lib/Term/UI.pm" >0.40 (BINGOS on 2014-01-01)</option> <option value="/release/BINGOS/Term-UI-0.38/view/lib/Term/UI.pm" >0.38 (BINGOS on 2013-09-23)</option> <option value="/release/BINGOS/Term-UI-0.36/view/lib/Term/UI.pm" >0.36 (BINGOS on 2013-06-05)</option> <option value="/release/BINGOS/Term-UI-0.34/view/lib/Term/UI.pm" >0.34 (BINGOS on 2013-01-22)</option> <option value="/release/BINGOS/Term-UI-0.32/view/lib/Term/UI.pm" >0.32 (BINGOS on 2012-11-10)</option> <option value="/release/BINGOS/Term-UI-0.30/view/lib/Term/UI.pm" >0.30 (BINGOS on 2011-12-21)</option> <option value="/release/BINGOS/Term-UI-0.28/view/lib/Term/UI.pm" >0.28 (BINGOS on 2011-12-21)</option> <option value="/release/BINGOS/Term-UI-0.26/view/lib/Term/UI.pm" >0.26 (BINGOS on 2011-02-09)</option> <option value="/release/BINGOS/Term-UI-0.24/view/lib/Term/UI.pm" >0.24 (BINGOS on 2011-01-12)</option> <option value="/release/BINGOS/Term-UI-0.22/view/lib/Term/UI.pm" >0.22 (BINGOS on 2011-01-07)</option> </optgroup> </select> <a data-keyboard-shortcut="g d" class="release-name" href="/dist/Term-UI">Term-UI-0.50</a> </div> <span class="river-gauge-gauge"> <svg width="24px" height="15px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g> <title> River stage three • 11 direct dependents • 739 total dependents </title> <rect x="0" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="5" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="10" y="0" width="4" height="15" fill="#7ea3f2" /> <rect x="15" y="0" width="4" height="15" fill="#e4e2e2" /> <rect x="20" y="0" width="4" height="15" fill="#e4e2e2" /> </g> </svg> </span> <div id="Term-UI-fav" class="show-logged-in"> <form action="/account/favorite/add" style="display: inline" method="POST"> <input type="hidden" name="remove" value="0"> <input type="hidden" name="release" value="Term-UI-0.50"> <input type="hidden" name="author" value="BINGOS"> <input type="hidden" name="distribution" value="Term-UI"> <button type="submit" class="favorite highlight"><span>5</span> ++</button> </form> </div> <div class="show-logged-out"> <button class="fav-not-logged-in favorite highlight"><span>5</span> ++</button> </div> / <span>Term::UI</span> </div> </div> <main class="content"> <nav class="toc"> <div class="toc-header"><strong>Contents</strong></div> <ul> <li><a href="#NAME">NAME</a></li> <li><a href="#SYNOPSIS">SYNOPSIS</a></li> <li><a href="#DESCRIPTION">DESCRIPTION</a></li> <li><a href="#HOW-IT-WORKS">HOW IT WORKS</a></li> <li><a href="#METHODS">METHODS</a> <ul> <li><a href="#%24reply-%3D-%24term-%3Eget_reply(-prompt-%3D%3E-%27question%3F%27%2C-%5Bchoices-%3D%3E-%5C%40list%2C-default-%3D%3E-%24list%5B0%5D%2C-preput-%3D%3E-%22text-to-put-as-default-user-input%22%2C-multi-%3D%3E-BOOL%2C-print_me-%3D%3E-%22extra-text-to-print-%26-record%22%2C-allow-%3D%3E-%24ref%5D-)%3B">$reply = $term->get_reply( prompt => 'question?', [choices => \@list, default => $list[0], preput => "text to put as default user input", multi => BOOL, print_me => "extra text to print & record", allow => $ref] );</a></li> <li><a href="#%24bool-%3D-%24term-%3Eask_yn(-prompt-%3D%3E-%22your-question%22%2C-%5Bdefault-%3D%3E-(y%7C1%2Cn%7C0)%2C-print_me-%3D%3E-%22extra-text-to-print-%26-record%22%5D-)">$bool = $term->ask_yn( prompt => "your question", [default => (y|1,n|0), print_me => "extra text to print & record"] )</a></li> <li><a href="#(%24opts%2C-%24munged)-%3D-%24term-%3Eparse_options(-STRING-)%3B">($opts, $munged) = $term->parse_options( STRING );</a></li> <li><a href="#%24str-%3D-%24term-%3Ehistory_as_string">$str = $term->history_as_string</a></li> </ul> </li> <li><a href="#GLOBAL-VARIABLES">GLOBAL VARIABLES</a> <ul> <li><a href="#%24Term%3A%3AUI%3A%3AVERBOSE">$Term::UI::VERBOSE</a></li> <li><a href="#%24Term%3A%3AUI%3A%3AAUTOREPLY">$Term::UI::AUTOREPLY</a></li> <li><a href="#%24Term%3A%3AUI%3A%3AINVALID">$Term::UI::INVALID</a></li> <li><a href="#%24Term%3A%3AUI%3A%3AHistory%3A%3AHISTORY_FH">$Term::UI::History::HISTORY_FH</a></li> </ul> </li> <li><a href="#EXAMPLES">EXAMPLES</a> <ul> <li><a href="#Basic-get_reply-sample">Basic get_reply sample</a></li> <li><a href="#get_reply-with-choices">get_reply with choices</a></li> <li><a href="#get_reply-with-choices-and-default">get_reply with choices and default</a></li> <li><a href="#get_reply-using-print_me-%26-multi">get_reply using print_me & multi</a></li> <li><a href="#get_reply-%26-allow">get_reply & allow</a></li> <li><a href="#an-elaborate-ask_yn-sample">an elaborate ask_yn sample</a></li> </ul> </li> <li><a href="#See-Also">See Also</a></li> <li><a href="#BUG-REPORTS">BUG REPORTS</a></li> <li><a href="#AUTHOR">AUTHOR</a></li> <li><a href="#COPYRIGHT">COPYRIGHT</a></li> </ul></nav> <div class="pod anchors"> <h1 id="NAME">NAME</h1> <p>Term::UI - Term::ReadLine UI made easy</p> <h1 id="SYNOPSIS">SYNOPSIS</h1> <pre><code>use Term::UI; use Term::ReadLine; my $term = Term::ReadLine->new('brand'); my $reply = $term->get_reply( prompt => 'What is your favourite colour?', choices => [qw|blue red green|], default => 'blue', ); my $bool = $term->ask_yn( prompt => 'Do you like cookies?', default => 'y', ); my $string = q[some_command -option --no-foo --quux='this thing']; my ($options,$munged_input) = $term->parse_options($string); ### don't have Term::UI issue warnings -- default is '1' $Term::UI::VERBOSE = 0; ### always pick the default (good for non-interactive terms) ### -- default is '0' $Term::UI::AUTOREPLY = 1; ### Retrieve the entire session as a printable string: $hist = Term::UI::History->history_as_string; $hist = $term->history_as_string;</code></pre> <h1 id="DESCRIPTION">DESCRIPTION</h1> <p><code>Term::UI</code> is a transparent way of eliminating the overhead of having to format a question and then validate the reply, informing the user if the answer was not proper and re-issuing the question.</p> <p>Simply give it the question you want to ask, optionally with choices the user can pick from and a default and <code>Term::UI</code> will DWYM.</p> <p>For asking a yes or no question, there's even a shortcut.</p> <h1 id="HOW-IT-WORKS"><a id="HOW"></a>HOW IT WORKS</h1> <p><code>Term::UI</code> places itself at the back of the <code>Term::ReadLine</code> <code>@ISA</code> array, so you can call its functions through your term object.</p> <p><code>Term::UI</code> uses <code>Term::UI::History</code> to record all interactions with the commandline. You can retrieve this history, or alter the filehandle the interaction is printed to. See the <code>Term::UI::History</code> manpage or the <code>SYNOPSIS</code> for details.</p> <h1 id="METHODS">METHODS</h1> <h2 id="$reply-=-$term->get_reply(-prompt-=>-'question?',-[choices-=>-\@list,-default-=>-$list[0],-preput-=>-"text-to-put-as-default-user-input",-multi-=>-BOOL,-print_me-=>-"extra-text-to-print-&-record",-allow-=>-$ref]-);"><a id="reply-term-get_reply-prompt-question-choices-list-default-list-0-preput-text-to-put-as-default-user-input-multi-BOOL-print_me-extra-text-to-print-record-allow-ref"></a>$reply = $term->get_reply( prompt => 'question?', [choices => \@list, default => $list[0], preput => "text to put as default user input", multi => BOOL, print_me => "extra text to print & record", allow => $ref] );</h2> <p><code>get_reply</code> asks a user a question, and then returns the reply to the caller. If the answer is invalid (more on that below), the question will be reposed, until a satisfactory answer has been entered.</p> <p>You have the option of providing a list of choices the user can pick from using the <code>choices</code> argument. If the answer is not in the list of choices presented, the question will be reposed.</p> <p>If you provide a <code>default</code> answer, this will be returned when either <code>$AUTOREPLY</code> is set to true, (see the <code>GLOBAL VARIABLES</code> section further below), or when the user just hits <code>enter</code>.</p> <p>The <code>preput</code> argument allows to specify a text that will be inserted to the prompt line as the initial input which may be edited, deleted or accepted by the user. If you supply the empty string as the <code>preput</code> argument then the <code>default</code> value will be preputted. It will only work if the underlying readline module provide support for it (now it is supported only by the <code>Term::Readline::Gnu</code>).</p> <p>You can indicate that the user is allowed to enter multiple answers by toggling the <code>multi</code> flag. Note that a list of answers will then be returned to you, rather than a simple string.</p> <p>By specifying an <code>allow</code> handler, you can yourself validate the answer a user gives. This can be any of the types that the Params::Check <code>allow</code> function allows, so please refer to that manpage for details.</p> <p>Finally, you have the option of adding a <code>print_me</code> argument, which is simply printed before the prompt. It's printed to the same file handle as the rest of the questions, so you can use this to keep track of a full session of Q&A with the user, and retrieve it later using the <code>Term::UI->history_as_string</code> function.</p> <p>See the <code>EXAMPLES</code> section for samples of how to use this function.</p> <h2 id="$bool-=-$term->ask_yn(-prompt-=>-"your-question",-[default-=>-(y|1,n|0),-print_me-=>-"extra-text-to-print-&-record"]-)"><a id="bool-term-ask_yn-prompt-your-question-default-y-1-n-0-print_me-extra-text-to-print-record"></a>$bool = $term->ask_yn( prompt => "your question", [default => (y|1,n|0), print_me => "extra text to print & record"] )</h2> <p>Asks a simple <code>yes</code> or <code>no</code> question to the user, returning a boolean indicating <code>true</code> or <code>false</code> to the caller.</p> <p>The <code>default</code> answer will automatically returned, if the user hits <code>enter</code> or if <code>$AUTOREPLY</code> is set to true. See the <code>GLOBAL VARIABLES</code> section further below.</p> <p>Also, you have the option of adding a <code>print_me</code> argument, which is simply printed before the prompt. It's printed to the same file handle as the rest of the questions, so you can use this to keep track of a full session of Q&A with the user, and retrieve it later using the <code>Term::UI->history_as_string</code> function.</p> <p>See the <code>EXAMPLES</code> section for samples of how to use this function.</p> <h2 id="($opts,-$munged)-=-$term->parse_options(-STRING-);"><a id="opts-munged-term-parse_options-STRING"></a>($opts, $munged) = $term->parse_options( STRING );</h2> <p><code>parse_options</code> will convert all options given from an input string to a hash reference. If called in list context it will also return the part of the input string that it found no options in.</p> <p>Consider this example:</p> <pre><code>my $str = q[command --no-foo --baz --bar=0 --quux=bleh ] . q[--option="some'thing" -one-dash -single=blah' arg]; my ($options,$munged) = $term->parse_options($str); ### $options would contain: ### $options = { 'foo' => 0, 'bar' => 0, 'one-dash' => 1, 'baz' => 1, 'quux' => 'bleh', 'single' => 'blah\'', 'option' => 'some\'thing' }; ### and this is the munged version of the input string, ### ie what's left of the input minus the options $munged = 'command arg';</code></pre> <p>As you can see, you can either use a single or a double <code>-</code> to indicate an option. If you prefix an option with <code>no-</code> and do not give it a value, it will be set to 0. If it has no prefix and no value, it will be set to 1. Otherwise, it will be set to its value. Note also that it can deal fine with single/double quoting issues.</p> <h2 id="$str-=-$term->history_as_string"><a id="str-term-history_as_string"></a>$str = $term->history_as_string</h2> <p>Convenience wrapper around <code>Term::UI::History->history_as_string</code>.</p> <p>Consult the <code>Term::UI::History</code> man page for details.</p> <h1 id="GLOBAL-VARIABLES"><a id="GLOBAL"></a>GLOBAL VARIABLES</h1> <p>The behaviour of Term::UI can be altered by changing the following global variables:</p> <h2 id="$Term::UI::VERBOSE"><a id="Term::UI::VERBOSE"></a>$Term::UI::VERBOSE</h2> <p>This controls whether Term::UI will issue warnings and explanations as to why certain things may have failed. If you set it to 0, Term::UI will not output any warnings. The default is 1;</p> <h2 id="$Term::UI::AUTOREPLY"><a id="Term::UI::AUTOREPLY"></a>$Term::UI::AUTOREPLY</h2> <p>This will make every question be answered by the default, and warn if there was no default provided. This is particularly useful if your program is run in non-interactive mode. The default is 0;</p> <h2 id="$Term::UI::INVALID"><a id="Term::UI::INVALID"></a>$Term::UI::INVALID</h2> <p>This holds the string that will be printed when the user makes an invalid choice. You can override this string from your program if you, for example, wish to do localization. The default is <code>Invalid selection, please try again: </code></p> <h2 id="$Term::UI::History::HISTORY_FH"><a id="Term::UI::History::HISTORY_FH"></a>$Term::UI::History::HISTORY_FH</h2> <p>This is the filehandle all the print statements from this module are being sent to. Please consult the <code>Term::UI::History</code> manpage for details.</p> <p>This defaults to <code>*STDOUT</code>.</p> <h1 id="EXAMPLES">EXAMPLES</h1> <h2 id="Basic-get_reply-sample"><a id="Basic"></a>Basic get_reply sample</h2> <pre><code>### ask a user (with an open question) for their favourite colour $reply = $term->get_reply( prompt => 'Your favourite colour? );</code></pre> <p>which would look like:</p> <pre><code>Your favourite colour?</code></pre> <p>and <code>$reply</code> would hold the text the user typed.</p> <h2 id="get_reply-with-choices"><a id="get_reply"></a>get_reply with choices</h2> <pre><code>### now provide a list of choices, so the user has to pick one $reply = $term->get_reply( prompt => 'Your favourite colour?', choices => [qw|red green blue|] );</code></pre> <p>which would look like:</p> <pre><code> 1> red 2> green 3> blue Your favourite colour?</code></pre> <p><code>$reply</code> will hold one of the choices presented. <code>Term::UI</code> will repose the question if the user attempts to enter an answer that's not in the list of choices. The string presented is held in the <code>$Term::UI::INVALID</code> variable (see the <code>GLOBAL VARIABLES</code> section for details.</p> <h2 id="get_reply-with-choices-and-default"><a id="get_reply1"></a>get_reply with choices and default</h2> <pre><code>### provide a sensible default option -- everyone loves blue! $reply = $term->get_reply( prompt => 'Your favourite colour?', choices => [qw|red green blue|], default => 'blue' );</code></pre> <p>which would look like:</p> <pre><code> 1> red 2> green 3> blue Your favourite colour? [3]:</code></pre> <p>Note the default answer after the prompt. A user can now just hit <code>enter</code> (or set <code>$Term::UI::AUTOREPLY</code> -- see the <code>GLOBAL VARIABLES</code> section) and the sensible answer 'blue' will be returned.</p> <h2 id="get_reply-using-print_me-&-multi"><a id="get_reply2"></a><a id="get_reply-using-print_me-multi"></a>get_reply using print_me & multi</h2> <pre><code>### allow the user to pick more than one colour and add an ### introduction text @reply = $term->get_reply( print_me => 'Tell us what colours you like', prompt => 'Your favourite colours?', choices => [qw|red green blue|], multi => 1 );</code></pre> <p>which would look like:</p> <pre><code>Tell us what colours you like 1> red 2> green 3> blue Your favourite colours?</code></pre> <p>An answer of <code>3 2 1</code> would fill <code>@reply</code> with <code>blue green red</code></p> <h2 id="get_reply-&-allow"><a id="get_reply3"></a><a id="get_reply-allow"></a>get_reply & allow</h2> <pre><code>### pose an open question, but do a custom verification on ### the answer, which will only exit the question loop, if ### the answer matches the allow handler. $reply = $term->get_reply( prompt => "What is the magic number?", allow => 42 );</code></pre> <p>Unless the user now enters <code>42</code>, the question will be reposed over and over again. You can use more sophisticated <code>allow</code> handlers (even subroutines can be used). The <code>allow</code> handler is implemented using <code>Params::Check</code>'s <code>allow</code> function. Check its manpage for details.</p> <h2 id="an-elaborate-ask_yn-sample"><a id="an"></a>an elaborate ask_yn sample</h2> <pre><code>### ask a user if he likes cookies. Default to a sensible 'yes' ### and inform him first what cookies are. $bool = $term->ask_yn( prompt => 'Do you like cookies?', default => 'y', print_me => 'Cookies are LOVELY!!!' );</code></pre> <p>would print:</p> <pre><code>Cookies are LOVELY!!! Do you like cookies? [Y/n]:</code></pre> <p>If a user then simply hits <code>enter</code>, agreeing with the default, <code>$bool</code> would be set to <code>true</code>. (Simply hitting 'y' would also return <code>true</code>. Hitting 'n' would return <code>false</code>)</p> <p>We could later retrieve this interaction by printing out the Q&A history as follows:</p> <pre><code>print $term->history_as_string;</code></pre> <p>which would then print:</p> <pre><code>Cookies are LOVELY!!! Do you like cookies? [Y/n]: y</code></pre> <p>There's a chance we're doing this non-interactively, because a console is missing, the user indicated he just wanted the defaults, etc.</p> <p>In this case, simply setting <code>$Term::UI::AUTOREPLY</code> to true, will return from every question with the default answer set for the question. Do note that if <code>AUTOREPLY</code> is true, and no default is set, <code>Term::UI</code> will warn about this and return <code>undef</code>.</p> <h1 id="See-Also"><a id="See"></a>See Also</h1> <p><code>Params::Check</code>, <code>Term::ReadLine</code>, <code>Term::UI::History</code></p> <h1 id="BUG-REPORTS"><a id="BUG"></a>BUG REPORTS</h1> <p>Please report bugs or other issues to <bug-term-ui@rt.cpan.org<gt>.</p> <h1 id="AUTHOR">AUTHOR</h1> <p>This module by Jos Boumans <kane@cpan.org>.</p> <h1 id="COPYRIGHT">COPYRIGHT</h1> <p>This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.</p></div> <div id="metacpan_install-instructions-dialog" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Module Install Instructions</h4> </div> <div class="modal-body"> <p>To install Term::UI, copy and paste the appropriate command in to your terminal.</p> <p><a href="/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p> <pre><code>cpanm Term::UI</code></pre> <p><a href="/pod/CPAN">CPAN shell</a></p> <pre><code>perl -MCPAN -e shell install Term::UI</code></pre> <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p> </div> <div class="modal-footer"> <a href="#" data-dismiss="modal" class="btn">Close</a> </div> </div> </div> </div> </main> <div class="content-pagination"> </div> </div> <footer class="footer"> <div class="footer-container"> <div class="footer-social"> <div class="footer-link footer-logo"> <a href="/"> <img src="/static/images/metacpan-logo.svg" alt="MetaCPAN" /> </a> </div> <a class="footer-social-link" href="https://github.com/metacpan"> <i class="fab fa-github-square"></i> </a> <a class="footer-social-link" href="https://fosstodon.org/@metacpan"> <i class="fab fa-mastodon"></i> </a> </div> <div class="footer-links"> <div class="footer-link"> <a href="/about">About</a> </div> <div class="footer-link"> <a href="/about/sponsors">Sponsor</a> </div> <div class="footer-link"> <a href="https://grep.metacpan.org">grep::cpan</a> </div> <div class="footer-link"> <a href="/recent">Recent</a> </div> <div class="footer-link"> <a href="/about/faq">FAQ</a> </div> <div class="footer-link"> <a href="/tools">Tools</a> </div> <div class="footer-link"> <a href="https://fastapi.metacpan.org/">API</a> </div> <div class="footer-link"> <a href="https://www.perl.org/">Perl.org</a> </div> </div> <div class="footer-sponsors"> <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener"> <img class="footer-sponsor-bytemark" src="/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener"> <img class="footer-sponsor-liquidweb" src="/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener"> <img class="footer-sponsor-deriv" src="/static/images/sponsors/deriv.svg" alt="Deriv logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener"> <img class="footer-sponsor-geocode" src="/static/images/sponsors/geocodelogo.svg" alt="Geocode logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener"> <img class="footer-sponsor-fastly" src="/static/images/sponsors/fastly_logo.svg" alt="Fastly logo"> </a> <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener"> <img class="footer-sponsor-opencage" src="/static/images/sponsors/open-cage.svg" alt="OpenCage logo"> </a> <!-- Added 2024-07-22 --> <a class="footer-sponsor-link" target="_blank" href="https://www.elastic.co/" rel="noopener"> <img class="footer-sponsor-elastic" src="/static/images/sponsors/elastic.svg" alt="Elastic logo"> </a> <!-- Added 2024-07-22 --> <a class="footer-sponsor-link" target="_blank" href="https://route4me.com/" rel="noopener"> <img class="footer-sponsor-route4me" src="/static/images/sponsors/route4me.png" alt="Route4Me logo"> </a> </div> </div> </footer> <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Keyboard Shortcuts</h4> </div> <div class="modal-body row"> <div class="col-md-6"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>Global</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>s</kbd> </td> <td>Focus search bar</td> </tr> <tr> <td class="keys"> <kbd>?</kbd> </td> <td>Bring up this help dialog</td> </tr> </tbody> </table> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>GitHub</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>g</kbd> <kbd>p</kbd> </td> <td>Go to pull requests</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>i</kbd> </td> <td>go to github issues (only if github is preferred repository)</td> </tr> </tbody> </table> </div> <div class="col-md-6"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>POD</th> </tr> </thead> <tbody> <tr> <td class="keys"> <kbd>g</kbd> <kbd>a</kbd> </td> <td>Go to author</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>c</kbd> </td> <td>Go to changes</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>i</kbd> </td> <td>Go to issues</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>d</kbd> </td> <td>Go to dist</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>r</kbd> </td> <td>Go to repository/SCM</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>s</kbd> </td> <td>Go to source</td> </tr> <tr> <td class="keys"> <kbd>g</kbd> <kbd>b</kbd> </td> <td>Go to file browse</td> </tr> </tbody> </table> </div> <div class="col-md-12"> <table class="table keyboard-shortcuts"> <thead> <tr> <th></th> <th>Search terms</th> </tr> </thead> <tbody> <tr> <td><em>module:</em> (e.g. <a href="/search?q=module%3APlugin">module:Plugin</a>)</td> </tr> <tr> <td><em>distribution:</em> (e.g. <a href="/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td> </tr> <tr> <td><em>author:</em> (e.g. <a href="/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td> </tr> <tr> <td><em>version:</em> (e.g. <a href="/search?q=version%3A1.00">version:1.00</a>)</td> </tr> </tbody> </table> </div> </div> <div class="modal-footer"></div> </div> </div> </div> </body> </html>