nktj_cli
v1.0.3
Published
TypeScript(Node.js) Consoller.
Downloads
3
Readme
Nktj CLI
Console control package for TypeScript (Node.js).
- Install
- Output
- Output (With line breaks)
- Specifying indentation
- Colored text output
- Input
- Output of newline
- Command Aregments
- Command Aregments on Option
# install
npm i nktj_cli# Output
CLI.out("Hallo World.");The output result is as follows.
Hallo World.Code with method chaining.
CLI.out("Hallo World.").out("....OK");The output result is as follows.
Hallo World.....OK# Output (With line breaks)
CLI.outn("Hallo World.");The output result is as follows.
Hallo World.Code with method chaining.
CLI.outn("Hallo World.").outn("....OK");;The output result is as follows.
Hallo World.
....OK# Specifying indentation
CLI.outn("Hallo World.");
CLI.setIndent(5).outn("....OK");The output result is as follows.
Hallo World.
....OKIndentation continues until the next setIndent command is encountered.
CLI.outn("Hallo World.");
CLI.setIndent(5).outn("....OK");
CLI.outn("....description");The output result is as follows.
Hallo World.
....OK
....description# Colored text output
To specify colored text, use the Color enumeration as the second argument to the out or outn method.
The following will be output in red:
import { CLI, Color } from "nktj_cli";
...
CLI.outn("Red Text Sample...", Color.Red);To specify a color origin that is not specified in the Color enumeration, use the setColorOrigin method.
(Specify RGB with Array)
CLI.outn(CLI.setColorOrigin("Original Color TExt...", [100,200,300]));To use colored text for intermediate weather, use setColor.
For example, to make only the "#" part green, write it as follows:
CLI.out(CLI.setColor("#", Color.Green) + " Text Text Text...");# Input
To get the input value from standard input,
specify the in method and use async/await to get the return value.
CLI.outn("please keyword :");
const value = await CLI.in();By adding arguments, you can specify the output before the input.
const value = await CLI.in("please keyword");# Output of newline
The br method creates a new line.
When this method is used, if an indent is specified,
a space of the specified indent is output after the line break.
Indentation settings are described here
CLI.outn("Hallo World.");
CLI.br();
CLI.outn("....OK");The same can be done with method chaining as shown below.
CLI
.outn("Hallo World.")
.br()
.outn("....OK")
;# Command Aregments
To get the arguments when a command is executed, use the getArgs method.
This method only gets simple argument values, excluding option values with --.
const args = CLI.getArgs();For example, if you run the following command:
$ node . aaa bbb ccccThe results obtained by getArgs are as follows.
["aaa", "bbb", "cccc"]# Command Aregments on Option
To get option values from arguments when executing a command, use the getArgsOption method.
const argsOption = CLI.getArgsOption();For example, if you run the following command:
$ node . aaaa --name abcdefg --mode 1The results obtained by getArgsOption are as follows.
In this case, "aaaa" is not retrieved, so to retrieve it, use getArgs
{
name: "abcdefg",
mode: 1,
}