Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/cli.ts

A JavaScript extension package for building strong and modern applications.
Latest
import * as ayonliJsext from "https://deno.land/x/ayonli_jsext@v0.9.72/cli.ts";

Useful utility functions for interacting with the terminal.

NOTE: Despite the name of this module, many of its functions can also be used in the browser environment.

Variables

The command-line arguments passed to the program.

^H - Backspace on Linux and Windows

^M - Enter on macOS and Windows (CRLF)

^A - Start of line

^C - Cancel

^E - End of line

^? - Backspace on macOS

^[ - Escape

^J - Enter on Linux

^I - Tab

Disable alternate screen buffer

Enable alternate screen buffer

Clear the current line

Clear the screen from the cursor down

Clear the left side of the cursor

Clear the right side of the cursor

Clear the entire screen

Clear the screen from the cursor up

Hide the cursor

Disable mouse tracking

Enable mouse tracking

Disable mouse wheel scrolling

Enable mouse wheel scrolling

Disable bracketed paste mode

Enable bracketed paste mode

Show the cursor

Disable line wrapping

Enable line wrapping

v
isTsRuntime
deprecated

Whether the standard IO is a text terminal.

v
platform
deprecated

Functions

Returns the width of a single character.

Opens the given file in a text editor.

Returns the current size of the application window.

Returns true if the given data is a typing input. That is, it is not a control key, navigation key, or function key.

Checks if the program is running in Windows Subsystem for Linux.

Requests the standard input to be used only by the given task until it is completed.

Moves the cursor to the left base on the width of the given string.

Moves the cursor to the right base on the width of the given string.

Parses the given CLI arguments into an object.

Executes the script inside PowerShell as if they were typed at the PowerShell command prompt.

Quotes a string to be used as a single argument to a shell command.

Reads a chunk of data from the standard input. This could be a single key stroke, or a multi-byte sequence for input from an IME.

Executes a command in the terminal and returns the exit code and outputs.

Returns the width of a string.

Executes a command with elevated privileges using sudo (or UAC in Windows).

Returns the path of the given command if it exists in the system, otherwise returns null.

Writes a chunk of data to the standard output.

Writes a chunk of data to the standard output synchronously.

Interfaces

The result of command execution functions such as the run, powershell and sudo.

Options for parsing CLI arguments, used by the parseArgs function.

Options for the sudo function.