π‘ fine-tuning for console
| ποΈ Library | @jaisocx/command-line |
π·οΈ ver.: 1.2.4 |
| π Updated | Winter 2026 | Mon Jan 19 03:29:44 UTC 2026 |
| π Size | π Folder: 60 KB | π¦ Tarball: _ KB | π .js: 5 KB |
| β‘ JS Engine | π Browser: β no | π§ Express: β yes | π₯οΈ Console: β yes |
Just a fine-tuning little js library for console javascript.
node example.js --arg1="value1" --argBC="Another Value 2" --debug
{ "arg1": "value1", "argBC": "Another Value 2", "debug": true }
The very base library,
installable via yarn or npm,
written in typescript programming language.
Supports bash key-value args, and provides in ts or js code as a js variable of js datatype Object.
The only js class CommandLineArgs with the interface,
was thought for reading command line args,
sent from console, in another javascript function.
Other .js or .ts files are for the infrastructure of this package,
like for example,
the current README.md is for the documentation
about this library.
60 KB ( sixty kilobyte ) library folderβs filesize
π software_labels/
software_tm_label_jaisocx.svg
π src/
index.ts
CommandLineArgsInterface.ts
CommandLineArgs.ts
π example/
CommandArgsObjectExample.ts
invokeJsClassExample.ts
π transpiled/
π CommonJS/
CommandLineArgs.js
...
...
π example/
invokeJsClassExample.js
...
π ESNext/
CommandLineArgs.js
...
...
π example/
invokeJsClassExample.js
...
package.json
π README.md
2 code lines ( bash sh )
# invokes the .js from example below 'ts coding example'
node invokeJsInConsoleExample.js --Root="/home/user/MyProject" --sitesToolPath="sites_tools/SitesTool"
src/CommandLineArgsInterface.ts
interface CommandLineArgsInterface {
getCommandLineArgs(): object;
getAfterReadNTransformed(): object;
readCommandLineArgs(): CommandLineArgsInterface;
transformCommandLineArgs(): CommandLineArgsInterface;
}
10 - 30 code lines ( ts js )
console.log( (new CommandLineArgs()).getAfterReadNTransformed() );
// Script Name: invokeJsInConsoleExample.js
// invoked in bash terminal like this:
// $_ node invokeJsInConsoleExample.js --Root="/home/user/MyProject" --sitesToolPath="sites_tools/SitesTool"
import * as path from "node:path";
import { CommandLineArgs } from "@jaisocx/command-line";
type CommandArgsObject = {
Root: "",
sitesToolPath: ""
};
function invokeJsInConsoleExample(): number {
// NEW INSTANCE OF THE MAIN CLASS IN THIS LIBRARY ( CommandLineArgs )
let commandLineArgsInstance: CommandLineArgs = new CommandLineArgs();
// FIRST GET ALL CLI ARGS INTO ONE js VARIABLE ( commandArgs )
let commandArgs: CommandArgsObject = commandLineArgsInstance
.readCommandLineArgs()
.transformCommandLineArgs()
.getCommandLineArgs() as CommandArgsObject;
// PRINT COMMAND LINE ARGS TO CONSOLE: console.log( commandArgs );
//
// SEES IN CONSOLE LIKE THIS:
// {
// Root: '/home/user/MyProject',
// sitesToolPath: 'sites_tools/SitesTool'
// }
console.log( commandArgs );
// GET CLI ARGS IN .js CODE JUST LIKE PROP OF A js OBJECT,
// the prop name after dot: commandArgs.Root
// or in square braces and quotes: commandArgs["Root"]
let resolvedSitesToolPath: any = path.resolve (
commandArgs.Root,
commandArgs["sitesToolPath"]
);
// OTHER CODE ...
let retVal: number = 2;
/**
Programm code ...
*/
return retVal;
}
// A ts OR js CODE LINE,
// NOT IN A CLASS OR FUNCTION DEFINITION,
// INVOKES AT ONCE WHEN A .js IS INVOKED IN CONSOLE VIA node
// $_ node invokeJsInConsoleExample.js --Root="/home/user/MyProject" --sitesToolPath="sites_tools/SitesTool"
// Invokes function,
// defined here on Line 14: function invokeJsInConsoleExample()
let retVal: number = invokeJsInConsoleExample();
// END OF .ts EXAMPLE
Have a nice day.
Elias, Software Architect of Jaisocx Company