shell

module:shell

Description:
  • Shell command interface for bksh

    Run bksh -help to see all registered shell commands.

    Special global command-line arguments:

    • -noexit - keep the shell running after executing the command
    • -exit - exit with error if no shell command found
    • -exit-timeout MS - will be set to ms to wait before exit for async actions to finish
    • -shell-delay MS - will wait before running the command to allow initialization complete

    Shell functions must be defined in shell.commands object, where myCommand is the command name in camel case for -my-command

    The function may return special values:

    • stop - stop processing commands and create REPL
    • continue - do not exit and continue processing other commands or end with REPL

    all other values will result in returning from the run assuming the command will decide what to do, exit or continue running, no REPL is created

Source:
Example
const { shell } = require("backendjs");

shell.commands.myCommand = function(options) {
   console.log("hello");
   return "continue"
}
// Calling `bksh -my-command` it will run this command.