@kawu/console-kit
v11.0.5
Published
A `fast`, `light weight`, `minimalist` and `reliable` module to log stuff easly and more understable.
Downloads
276
Readme
Console-kit
A fast
, light weight
, minimalist
and reliable
module to log stuff easly and more understable.
Installation
Use this command to add Console-kit
npm i @kawu/console-kit
Usage
TS
import { ConsoleKit } from "@kawu/console-kit";
const consoleKit = new ConsoleKit();
JS
const { ConsoleKit } = require("@kawu/console-kit");
const consoleKit = new ConsoleKit();
Logging
When logging what's going on in your application is crucial, I have dedicated functions for every situation.
Comments
consoleKit.comment(CommentOptions);
// CommentOptions
message: string;
timestamp: boolean; // Not required
Success
consoleKit.success(CheckOptions);
// CheckOptions
message: string;
timestamp: boolean; // Not required
Info
consoleKit.info(InfoOptions);
// InfoOptions
message: string;
timestamp: boolean; // Not required
Warn
consoleKit.warn(WarnOptions);
// WarnOptions
message: string;
timestamp: boolean; // Not required
Error
consoleKit.error(ErrorOptions);
// ErrorOptions
message: string;
timestamp: boolean; // Not required
Loading
This is kinda usefull to tell that your terminal is doing background stuff.
Start loader
consoleKit.startLoading(StartLoaderOptions);
// StartLoaderOptions
message: string;
timestamp: boolean; // Not required
Stop loader
consoleKit.stopLoading(StopLoaderOptions);
// StopLoaderOptions
clearLine: boolean; // Remove the loading line if true
Progress Bar
Like the loading but we know when the loading will finish.
Start progress bar
consoleKit.startProgress(StartProgressOptions);
// StartProgressOptions
message: string;
percentage: number;
timestamp: boolean; // Not required
Edit the actual progress bar
consoleKit.editProgress(EditProgressOptions);
// EditProgressOptions
percentage: number;
message: string;
End progress bar
consoleKit.endProgress(EndProgressOptions);
// EndProgressOptions
clearLine: boolean; // Remove the progress bar line if true
Prompt
If your user need to give you data, then the prompt is a good way to go.
Usage
consoleKit.prompt(PromptOptions);
// PromptOptions
message: string;
character: string; // Not required -- If you wish to replace "?", put your own icon here
Output
string;
YesNo
It's like prompt but for boolean values.
Usage
consoleKit.yesno(YesNoOptions);
// YesNoOptions
message: string;
defaultValue: boolean; // true = yes | false = no
Output
If the default value is false
and the user send for example lol
then the output will be false
because he didn't put no
/n
or yes
/y
.
boolean;
Select
You have a list and your user have to select an item inside a list, then this will do the job.
consoleKit.select(SelectOptions);
values: Array<string>;
defaultValueIndex: number; // Not required -- Index number of the values array
selectedText: string; // Not required -- Custom the "[ • ]" (Item selected)
unselectedText: string; // Not required -- Custom the "[ ]" (Item not selected)
cleanafter: boolean; // Not required -- Remove the selection of the terminal when user finished