NAME

cs::Upd - update dynamic progress line


SYNOPSIS

        use cs::Upd;
        out(message);
        nl(message);
        err(message-with-\n);
        $U = new cs::Upd (STATUSTTY, TTY);
        $U->Out(message);
        $U->Nl(message);
        $U->Err(message-with-\n);


DESCRIPTION

This module provides a progress line for reporting actions of a script, on STDERR by default, though any stream may be used for this purpose. It provides out and nl functions for setting the progress line and printing an actual scrolled line respectively, err for printing error messages, and intercepts perl's warn and die calls to do the right thing.


GENERAL FUNCTIONS

setDefault(STREAM)

Make the default update stream STREAM. The default default is STDERR.

out(message)

Display message in the progress line of the default object (normally attached to STDERR).

nl(message)

Print message and a newline.

err(message)

Print message to the STDERR stream.

promptfor(prompt,FILE)

Issue the prompt via the default object then read a line from the stream FILE. If omitted, FILE defaults to STDIN. Return the input line.


OBJECT CREATION

new cs::Upd (FILE,mode)

Create a new cs::Upd object attached to the stream FILE in the mode mode. If FILE is omitted, use STDOUT. mode is one of TTY or FILE. In TTY mode, cs::Upd makes use of the \r and \b characters to do an optimal rewrite of the line (to use minimum bandwidth for users operating over a low bandwidth connection) when the out function or Out method is called. In FILE mode, simply prints a \n and the new line. If mode is omitted the stream FILE is stat()ed to choose a mode.


OBJECT METHODS

SetMode(mode)

Set the mode of the object to mode. If omitted, stat() the stream to choose a mode. If mode is TTY, try to set the clip width to the tty column count - 1.

Select()

Make this object the default for use by the out and nl functions.

PromptFor(prompt,FILE)

Issue the prompt and then read a line from the stream FILE. If omitted, FILE defaults to STDIN. Return the input line.

Ask(prompt,FILE)

Issue the prompt with `` (Y/n)? '' appended and then read a line from the stream FILE. If omitted, FILE defaults to STDIN. Return true if the line commences with a y.

Current()

Return the current content of the progress line.


AUTHOR

Cameron Simpson <cs@zip.com.au>