Namespace

cli

ts-workspace.cli

This script demonstrates a basic command-line interface (CLI) that counts down from 60 seconds and then exits.

sequenceDiagram participant User participant CLI participant Timer User->>CLI: Run script CLI->>User: Display initial message CLI->>Timer: Start countdown loop Every second Timer->>CLI: Decrement counter CLI->>User: Display current count end Timer->>CLI: Counter reaches 0 CLI->>User: Exit process
See:

View Source bin/cli.ts, line 2

Example

// Run the script
node cli.js

Members

number

# static constant counter

Used to track the remaining time in the countdown.

The countdown timer, initialized to 60 seconds.

View Source bin/cli.ts, line 33

Methods

# static iterator() → {void}

It uses setTimeout to create a delay of 1 second between each count. The function decrements the counter, logs the current count, and calls itself until the counter reaches 0. When the counter reaches 0, the process exits.

A recursive function that manages the countdown timer.

View Source bin/cli.ts, line 43

void