close
Skip to main content

@sys/cli@0.0.315
Built and signed on GitHub Actions

Works with
This package works with Deno, Browsers
This package works with Deno
This package works with Browsers
JSR Score100%
License
MIT
Downloads71/wk
Published2 weeks ago (0.0.315)

Tools for working with a command-line interfaces.

Command Line Interface

Tools for working with a command-line interfaces (cli).

  • Ansi colors
  • Table formatting
  • Prompting (user input)

Example

import { Cli, c } from '@sys/cli';

/**
 * Ansi colors:
 */
console.info(c.cyan('using color'));

/**
 * string: plain → ansi → plain:
 */
const text = `thing ${c.green('with')} color`;
const stripped = Cli.stripAnsi(text);


/**
 * Table formatting:
 */
const table = Cli.table([]);
table.push(['foo', 'bar']);
console.info(table.toString().trim())


/**
 * Prompting:
 */
const dirname = await Cli.Input.Text.prompt({
  message: 'Folder Name',
  default: 'foo',
  // Keep folder-name simple + safe: letters, numbers, dot, dash, underscore, slashes (no spaces).
  validate: (v: string) =>
    /^[\w.\-\/]+$/.test(v) || 'Use letters, numbers, ".", "-", "_" (and optional "/")',
});
Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@sys/cli

Import symbol

import * as cli from "@sys/cli";
or

Import directly with a jsr specifier

import * as cli from "jsr:@sys/cli";