mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
502 lines
26 KiB
HTML
502 lines
26 KiB
HTML
|
|
|
|
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>CLI Library — CodeIgniter4 4.0.0-beta.1 documentation</title>
|
|
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="../_static/ci-icon.ico"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="top" title="CodeIgniter4 4.0.0-beta.1 documentation" href="../index.html"/>
|
|
<link rel="up" title="Command Line Usage" href="index.html"/>
|
|
<link rel="next" title="CLIRequest Class" href="cli_request.html"/>
|
|
<link rel="prev" title="Custom CLI Commands" href="cli_commands.html"/>
|
|
|
|
|
|
<script src="../_static/js/modernizr.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search">
|
|
|
|
|
|
|
|
<a href="../index.html" class="icon icon-home"> CodeIgniter4
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../concepts/index.html">CodeIgniter4 Overview</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../incoming/index.html">Controllers and Routing</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../outgoing/index.html">Building Responses</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Working With Databases</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../models/index.html">Modeling Data</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../dbmgmt/index.html">Managing Databases</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Library Reference</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html">Testing</a></li>
|
|
</ul>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Command Line Usage</a><ul class="current">
|
|
<li class="toctree-l2"><a class="reference internal" href="cli.html">Running via the Command Line</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="cli_commands.html">Custom CLI Commands</a></li>
|
|
<li class="toctree-l2 current"><a class="current reference internal" href="#">CLI Library</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="cli_request.html">CLIRequest Class</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../extending/index.html">Extending CodeIgniter</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="../license.html">The MIT License (MIT)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="../changelogs/index.html">Change Logs</a></li>
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="../index.html">CodeIgniter4</a>
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
|
|
<ul class="wy-breadcrumbs">
|
|
|
|
<li><a href="../index.html">Docs</a> »</li>
|
|
|
|
<li><a href="index.html">Command Line Usage</a> »</li>
|
|
|
|
<li>CLI Library</li>
|
|
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<div class="section" id="cli-library">
|
|
<h1>CLI Library<a class="headerlink" href="#cli-library" title="Permalink to this headline">¶</a></h1>
|
|
<p>CodeIgniter’s CLI library makes creating interactive command-line scripts simple, including:</p>
|
|
<ul class="simple">
|
|
<li>Prompting the user for more information</li>
|
|
<li>Writing multi-colored text the terminal</li>
|
|
<li>Beeping (be nice!)</li>
|
|
<li>Showing progress bars during long tasks</li>
|
|
<li>Wrapping long text lines to fit the window.</li>
|
|
</ul>
|
|
<div class="contents local topic" id="contents">
|
|
<ul class="simple">
|
|
<li><a class="reference internal" href="#initializing-the-class" id="id1">Initializing the Class</a></li>
|
|
<li><a class="reference internal" href="#getting-input-from-the-user" id="id2">Getting Input from the User</a></li>
|
|
<li><a class="reference internal" href="#providing-feedback" id="id3">Providing Feedback</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="initializing-the-class">
|
|
<h2><a class="toc-backref" href="#id1">Initializing the Class</a><a class="headerlink" href="#initializing-the-class" title="Permalink to this headline">¶</a></h2>
|
|
<p>You do not need to create an instance of the CLI library, since all of it’s methods are static. Instead, you simply
|
|
need to ensure your controller can locate it via a <code class="docutils literal"><span class="pre">use</span></code> statement above your class:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="o"><?</span><span class="nx">php</span> <span class="k">namespace</span> <span class="nx">App\Controllers</span><span class="p">;</span>
|
|
|
|
<span class="k">use</span> <span class="nx">CodeIgniter\CLI\CLI</span><span class="p">;</span>
|
|
|
|
<span class="k">class</span> <span class="nc">MyController</span> <span class="k">extends</span> <span class="nx">\CodeIgniter\Controller</span>
|
|
<span class="p">{</span>
|
|
<span class="o">.</span> <span class="o">.</span> <span class="o">.</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The class is automatically initialized when the file is loaded the first time.</p>
|
|
</div>
|
|
<div class="section" id="getting-input-from-the-user">
|
|
<h2><a class="toc-backref" href="#id2">Getting Input from the User</a><a class="headerlink" href="#getting-input-from-the-user" title="Permalink to this headline">¶</a></h2>
|
|
<p>Sometimes you need to ask the user for more information. They might not have provided optional command-line
|
|
arguments, or the script may have encountered an existing file and needs confirmation before overwriting. This is
|
|
handled with the <code class="docutils literal"><span class="pre">prompt()</span></code> method.</p>
|
|
<p>You can provide a question by passing it in as the first parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$color</span> <span class="o">=</span> <span class="nx">CLI</span><span class="o">::</span><span class="na">prompt</span><span class="p">(</span><span class="s1">'What is your favorite color?'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>You can provide a default answer that will be used if the user just hits enter by passing the default in the
|
|
second parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$color</span> <span class="o">=</span> <span class="nx">CLI</span><span class="o">::</span><span class="na">prompt</span><span class="p">(</span><span class="s1">'What is your favorite color?'</span><span class="p">,</span> <span class="s1">'blue'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>You can restrict the acceptable answers by passing in an array of allowed answers as the second parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$overwrite</span> <span class="o">=</span> <span class="nx">CLI</span><span class="o">::</span><span class="na">prompt</span><span class="p">(</span><span class="s1">'File exists. Overwrite?'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'y'</span><span class="p">,</span><span class="s1">'n'</span><span class="p">]);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Finally, you can pass validation rules to the answer input as the third parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$email</span> <span class="o">=</span> <span class="nx">CLI</span><span class="o">::</span><span class="na">prompt</span><span class="p">(</span><span class="s1">'What is your email?'</span><span class="p">,</span> <span class="k">null</span><span class="p">,</span> <span class="s1">'required|valid_email'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
<div class="section" id="providing-feedback">
|
|
<h2><a class="toc-backref" href="#id3">Providing Feedback</a><a class="headerlink" href="#providing-feedback" title="Permalink to this headline">¶</a></h2>
|
|
<p><strong>write()</strong></p>
|
|
<p>Several methods are provided for you to provide feedback to your users. This can be as simple as a single status update
|
|
or a complex table of information that wraps to the user’s terminal window. At the core of this is the <code class="docutils literal"><span class="pre">write()</span></code>
|
|
method which takes the string to output as the first parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">write</span><span class="p">(</span><span class="s1">'The rain in Spain falls mainly on the plains.'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>You can change the color of the text by passing in a color name as the first parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">write</span><span class="p">(</span><span class="s1">'File created.'</span><span class="p">,</span> <span class="s1">'green'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This could be used to differentiate messages by status, or create ‘headers’ by using a different color. You can
|
|
even set background colors by passing the color name in as the third parameter:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">write</span><span class="p">(</span><span class="s1">'File overwritten.'</span><span class="p">,</span> <span class="s1">'light_red'</span><span class="p">,</span> <span class="s1">'dark_gray'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The following colors are available:</p>
|
|
<ul class="simple">
|
|
<li>black</li>
|
|
<li>dark_gray</li>
|
|
<li>blue</li>
|
|
<li>dark_blue</li>
|
|
<li>light_blue</li>
|
|
<li>green</li>
|
|
<li>light_green</li>
|
|
<li>cyan</li>
|
|
<li>light_cyan</li>
|
|
<li>red</li>
|
|
<li>light_red</li>
|
|
<li>purple</li>
|
|
<li>light_purple</li>
|
|
<li>light_yellow</li>
|
|
<li>yellow</li>
|
|
<li>light_gray</li>
|
|
<li>white</li>
|
|
</ul>
|
|
<p><strong>color()</strong></p>
|
|
<p>While the <code class="docutils literal"><span class="pre">write()</span></code> command will write a single line to the terminal, ending it with a EOL character, you can
|
|
use the <code class="docutils literal"><span class="pre">color()</span></code> method to make a string fragment that can be used in the same way, except that it will not force
|
|
an EOL after printing. This allows you to create multiple outputs on the same row. Or, more commonly, you can use
|
|
it inside of a <code class="docutils literal"><span class="pre">write()</span></code> method to create a string of a different color inside:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">write</span><span class="p">(</span><span class="s2">"fileA </span><span class="se">\t</span><span class="s2">"</span><span class="o">.</span> <span class="nx">CLI</span><span class="o">::</span><span class="na">color</span><span class="p">(</span><span class="s1">'/path/to/file'</span><span class="p">,</span> <span class="s1">'white'</span><span class="p">),</span> <span class="s1">'yellow'</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>This example would write a single line to the window, with <code class="docutils literal"><span class="pre">fileA</span></code> in yellow, followed by a tab, and then
|
|
<code class="docutils literal"><span class="pre">/path/to/file</span></code> in white text.</p>
|
|
<p><strong>error()</strong></p>
|
|
<p>If you need to output errors, you should use the appropriately named <code class="docutils literal"><span class="pre">error()</span></code> method. This writes light-red text
|
|
to STDERR, instead of STDOUT, like <code class="docutils literal"><span class="pre">write()</span></code> and <code class="docutils literal"><span class="pre">color()</span></code> do. This can be useful if you have scripts watching
|
|
for errors so they don’t have to sift through all of the information, only the actual error messages. You use it
|
|
exactly as you would the <code class="docutils literal"><span class="pre">write()</span></code> method:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">error</span><span class="p">(</span><span class="s1">'Cannot write to file: '</span><span class="o">.</span> <span class="nv">$file</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>wrap()</strong></p>
|
|
<p>This command will take a string, start printing it on the current line, and wrap it to a set length on new lines.
|
|
This might be useful when displaying a list of options with descriptions that you want to wrap in the current
|
|
window and not go off screen:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">color</span><span class="p">(</span><span class="s2">"task1</span><span class="se">\t</span><span class="s2">"</span><span class="p">,</span> <span class="s1">'yellow'</span><span class="p">);</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">wrap</span><span class="p">(</span><span class="s2">"Some long description goes here that might be longer than the current window."</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>By default the string will wrap at the terminal width. Windows currently doesn’t provide a way to determine
|
|
the window size, so we default to 80 characters. If you want to restrict the width to something shorter that
|
|
you can be pretty sure fits within the window, pass the maximum line-length as the second parameter. This
|
|
will break the string at the nearest word barrier so that words are not broken.</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Wrap the text at max 20 characters wide</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">wrap</span><span class="p">(</span><span class="nv">$description</span><span class="p">,</span> <span class="mi">20</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>You may find that you want a column on the left of titles, files, or tasks, while you want a column of text
|
|
on the right with their descriptions. By default, this will wrap back to the left edge of the window, which
|
|
doesn’t allow things to line up in columns. In cases like this, you can pass in a number of spaces to pad
|
|
every line after the first line, so that you will have a crisp column edge on the left:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Determine the maximum length of all titles</span>
|
|
<span class="c1">// to determine the width of the left column</span>
|
|
<span class="nv">$maxlen</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="nb">array_map</span><span class="p">(</span><span class="s1">'strlen'</span><span class="p">,</span> <span class="nv">$titles</span><span class="p">));</span>
|
|
|
|
<span class="k">for</span> <span class="p">(</span><span class="nv">$i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nv">$i</span> <span class="o"><=</span> <span class="nb">count</span><span class="p">(</span><span class="nv">$titles</span><span class="p">);</span> <span class="nv">$i</span><span class="o">++</span><span class="p">)</span>
|
|
<span class="p">{</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">write</span><span class="p">(</span>
|
|
<span class="c1">// Display the title on the left of the row</span>
|
|
<span class="nv">$title</span><span class="p">[</span><span class="nv">$i</span><span class="p">]</span><span class="o">.</span><span class="s1">' '</span><span class="o">.</span>
|
|
<span class="c1">// Wrap the descriptions in a right-hand column</span>
|
|
<span class="c1">// with its left side 3 characters wider than</span>
|
|
<span class="c1">// the longest item on the left.</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">wrap</span><span class="p">(</span><span class="nv">$descriptions</span><span class="p">[</span><span class="nv">$i</span><span class="p">],</span> <span class="mi">40</span><span class="p">,</span> <span class="nv">$maxlen</span><span class="o">+</span><span class="mi">3</span><span class="p">)</span>
|
|
<span class="p">);</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>Would create something like this:</p>
|
|
<div class="highlight-none"><div class="highlight"><pre><span></span>task1a Lorem Ipsum is simply dummy
|
|
text of the printing and typesetting
|
|
industry.
|
|
task1abc Lorem Ipsum has been the industry's
|
|
standard dummy text ever since the
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>newLine()</strong></p>
|
|
<p>The <code class="docutils literal"><span class="pre">newLine()</span></code> method displays a blank line to the user. It does not take any parameters:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">newLine</span><span class="p">();</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>clearScreen()</strong></p>
|
|
<p>You can clear the current terminal window with the <code class="docutils literal"><span class="pre">clearScreen()</span></code> method. In most versions of Windows, this will
|
|
simply insert 40 blank lines since Windows doesn’t support this feature. Windows 10 bash integration should change
|
|
this:</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CLI</span><span class="o">::</span><span class="na">clearScreen</span><span class="p">();</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>showProgress()</strong></p>
|
|
<p>If you have a long-running task that you would like to keep the user updated with the progress, you can use the
|
|
<code class="docutils literal"><span class="pre">showProgress()</span></code> method which displays something like the following:</p>
|
|
<div class="highlight-none"><div class="highlight"><pre><span></span>[####......] 40% Complete
|
|
</pre></div>
|
|
</div>
|
|
<p>This block is animated in place for a very nice effect.</p>
|
|
<p>To use it, pass in the current step as the first parameter, and the total number of steps as the second parameter.
|
|
The percent complete and the length of the display will be determined based on that number. When you are done,
|
|
pass <code class="docutils literal"><span class="pre">false</span></code> as the first parameter and the progress bar will be removed.</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$totalSteps</span> <span class="o">=</span> <span class="nb">count</span><span class="p">(</span><span class="nv">$tasks</span><span class="p">);</span>
|
|
<span class="nv">$currStep</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
|
|
|
|
<span class="k">foreach</span> <span class="p">(</span><span class="nv">$tasks</span> <span class="k">as</span> <span class="nv">$task</span><span class="p">)</span>
|
|
<span class="p">{</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">showProgress</span><span class="p">(</span><span class="nv">$currStep</span><span class="o">++</span><span class="p">,</span> <span class="nv">$totalSteps</span><span class="p">);</span>
|
|
<span class="nv">$task</span><span class="o">-></span><span class="na">run</span><span class="p">();</span>
|
|
<span class="p">}</span>
|
|
|
|
<span class="c1">// Done, so erase it...</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">showProgress</span><span class="p">(</span><span class="k">false</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>table()</strong></p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$thead</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'ID'</span><span class="p">,</span> <span class="s1">'Title'</span><span class="p">,</span> <span class="s1">'Updated At'</span><span class="p">,</span> <span class="s1">'Active'</span><span class="p">];</span>
|
|
<span class="nv">$tbody</span> <span class="o">=</span> <span class="p">[</span>
|
|
<span class="p">[</span><span class="mi">7</span><span class="p">,</span> <span class="s1">'A great item title'</span><span class="p">,</span> <span class="s1">'2017-11-15 10:35:02'</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span>
|
|
<span class="p">[</span><span class="mi">8</span><span class="p">,</span> <span class="s1">'Another great item title'</span><span class="p">,</span> <span class="s1">'2017-11-16 13:46:54'</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
|
|
<span class="p">];</span>
|
|
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">table</span><span class="p">(</span><span class="nv">$tbody</span><span class="p">,</span> <span class="nv">$thead</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<div class="highlight-none"><div class="highlight"><pre><span></span>+----+--------------------------+---------------------+--------+
|
|
| ID | Title | Updated At | Active |
|
|
+----+--------------------------+---------------------+--------+
|
|
| 7 | A great item title | 2017-11-16 10:35:02 | 1 |
|
|
| 8 | Another great item title | 2017-11-16 13:46:54 | 0 |
|
|
+----+--------------------------+---------------------+--------+
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>wait()</strong></p>
|
|
<p>Waits a certain number of seconds, optionally showing a wait message and
|
|
waiting for a key press.</p>
|
|
<div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// wait for specified interval, with countdown displayed</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">wait</span><span class="p">(</span><span class="nv">$seconds</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
|
|
|
|
<span class="c1">// show continuation message and wait for input</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">wait</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>
|
|
|
|
<span class="c1">// wait for specified interval</span>
|
|
<span class="nx">CLI</span><span class="o">::</span><span class="na">wait</span><span class="p">(</span><span class="nv">$seconds</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
<div class="articleComments">
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="cli_request.html" class="btn btn-neutral float-right" title="CLIRequest Class" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="cli_commands.html" class="btn btn-neutral" title="Custom CLI Commands" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
© Copyright 2014-2019 British Columbia Institute of Technology.
|
|
Last updated on Mar 06, 2019.
|
|
|
|
</p>
|
|
</div>
|
|
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT:'../',
|
|
VERSION:'4.0.0-beta.1',
|
|
COLLAPSE_INDEX:false,
|
|
FILE_SUFFIX:'.html',
|
|
HAS_SOURCE: false,
|
|
SOURCELINK_SUFFIX: ''
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../_static/js/theme.js"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function () {
|
|
SphinxRtdTheme.StickyNav.enable();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |