Skip to main content

ProgramArgs — Runtime CLI Arguments

Oidis applications accept command-line arguments that control runtime behavior such as debug mode, verbose logging, server lifecycle, and database operations. The ProgramArgs class parses these arguments and exposes them through getter/setter methods accessible anywhere in the application.

Access​

import { Loader } from "../Loader.js";

const args = Loader.getInstance().getProgramArgs();

if (args.IsDebug()) {
// debug-specific behavior
}

Every getter method on ProgramArgs also acts as a setter when called with an argument: args.IsDebug() reads the value, args.IsDebug(true) sets it.

Class Hierarchy​

ProgramArgs has a two-level inheritance chain:

PackageClassAdds
io-oidis-localhostProgramArgsCore flags (debug, verbose, server control, integrity checks)
io-oidis-hubProgramArgs extends ParentHub-specific flags (agent mode, DB reset)

Solution projects (e.g. IRMA) that extend Hub automatically inherit both levels. If a solution needs custom CLI flags, it can extend Hub's ProgramArgs and override processArg().

Localhost Flags (Base)​

These flags are available in all Oidis applications (localhost and hub-based).

Basic Options​

FlagShortMethodDescription
--help-h, /h, /?, help, ?IsHelp()Print help and wait for input
--version-v, /v, versionIsVersion()Print application name and version
--path-p, /p, pathIsPath()Print project base directory
--debugIsDebug()Enable debug mode
--verboseIsVerbose()Enable verbose output
--test-runIsTestRun()Mark as test run (also checks IS_WUI_TEST_RUN env var)
--log-level=NLogLevel()Set numeric log level

Server Control​

FlagMethodDescription
startStartServer()Start the server
stopStopServer()Stop a running server
restartRestartServer()Restart the server
list-routesListRoutes()Print all registered routes

Integrity & Configuration​

FlagMethodDescription
--selfcheckIsSelfCheck()Run self health check (pings the running server)
--update-verifyIsUpdateVerify()Self-update: a freshly downloaded release proves it boots (Loader.verifyRelease()), exit 0 or 1
--update-activateIsUpdateActivate()Self-update: detached activator switching the service installation to a verified release
--update-root=, --update-new=, --update-old=, --update-appdata=getUpdateArgs()Install root, new release, rollback release and appData of the activation
--integrity-checkIsIntegrityCheck()Run assembly integrity check
--ignored-checks=a,b,cgetIgnoredChecks()Comma-separated list of integrity checks to skip
--target=pathTargetBase()Target HTML file for localhost hosting
--with-mapping / --elastic-mappingElasticMapping()Trigger Elasticsearch mapping

Path Accessors​

These are not CLI flags but programmatic accessors set during application bootstrap:

MethodDescription
ProjectBase()Root directory of the project
BinBase()Binary/executable base directory
TargetBase()Build target base directory
AppDataPath()Application data directory (downloads, temp files, etc.)

Hub Flags (Extended)​

Hub-based applications add two flags on top of the localhost base:

FlagMethodDescription
--agentIsAgent()Run as agent instance (secondary role in multi-instance setup)
--reset-dbWithDBReset()Force database synchronization on startup

Debug Mode​

--debug enables debug mode which affects several runtime behaviors:

  • Puppeteer: Runs browsers in headed mode (visible window) instead of headless. Controlled via IPuppeteerExtractOptions.debug:
    private getExtractOptions() : IPuppeteerExtractOptions {
    return {debug: Loader.getInstance().getProgramArgs().IsDebug(), verbose: false};
    }
  • Logging: Extended debug log output via LogIt.Debug() calls throughout the application

Without --debug, Puppeteer runs headless and debug-level log messages are suppressed.

Usage Examples​

# Start server normally (headless, production-like)
node loader.min.js start

# Start in debug mode (Puppeteer headed, verbose logging)
node loader.min.js start --debug

# Start with verbose output and custom log level
node loader.min.js start --verbose --log-level=3

# Start as agent with DB reset
node loader.min.js start --agent --reset-db

# Print version and exit
node loader.min.js --version

# Run integrity check, skipping specific checks
node loader.min.js --integrity-check --ignored-checks=check1,check2

# List all registered routes
node loader.min.js list-routes

Argument Format​

ProgramArgs.Normalize() pre-processes raw CLI arguments into a consistent format before parsing. It supports:

  • Long flags: --debug, --log-level=3
  • Short flags: -h, -v, -p
  • Windows-style: /h, /v, /p (single character only)
  • Bare commands: start, stop, restart, help, version, path, list-routes
  • Key-value pairs: --target=path/to/file, --log-level=3, --ignored-checks=a,b,c
  • Quoted values: --target="path with spaces", --target='path with spaces'

Argument Parsing​

Normalize()​

Normalises a raw process.argv-style array by pairing flag keys with their values. Handles:

  • --key=value (equals assignment)
  • --key value (space-separated)
  • /k (Windows single-char style)
  • Quoted values with internal spaces: --key "my value" → stored as "my value"
public Normalize($args : string[]) : string[]

Parse()​

Parses and applies a normalised argument list. Called once at startup with the full process.argv array.

public Parse($args : string[]) : void

When no arguments are provided, IsHelp(true) is set automatically (shows help prompt).


Stdin Handler​

When IsHelp(), IsVersion(), or IsPath() are true, the application prints output and prompts for input via StdinManager. A custom handler can be set before Parse() to intercept that input:

Loader.getInstance().getProgramArgs().setStdinHandler(($input : string) : void => {
// re-parse the user-entered arguments
Loader.getInstance().getProgramArgs().Parse($input.split(" "));
});

Extension: Custom Args​

To add custom arguments, extend ProgramArgs and override processArg():

export class MyProgramArgs extends ProgramArgs {

private myFlag : boolean = false;

public MyFlag($value? : boolean) : boolean {
return this.myFlag = Property.Boolean(this.myFlag, $value);
}

protected processArg($key : string, $value : string) : boolean {
switch (StringUtils.ToLowerCase($key)) {
case "--my-flag":
this.MyFlag(true);
return true;
default:
return super.processArg($key, $value);
}
}
}

Register the custom class in EnvironmentArgs by returning it from createProgramArgs().


See also: Architecture Overview | Property | Commons Config