jaisocx_sites_tools

Command Line

πŸ’‘ 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

πŸ’‘ The aim of the setup

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.


πŸ“‚ Package Structure

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

πŸ“„ Bash Coding Example

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"

πŸ“„ Interfaces

src/CommandLineArgsInterface.ts


  interface CommandLineArgsInterface {

    getCommandLineArgs(): object;

    getAfterReadNTransformed(): object;

    readCommandLineArgs(): CommandLineArgsInterface;

    transformCommandLineArgs(): CommandLineArgsInterface;

  }
  

πŸ“„ Typescript Coding Example

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