You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
CommandHelper has a rich set of command line tools for various tasks. To use the
command line tools, run
java -jar CommandHelper.jar <arguments>
=== Explain Like I'm 5 ===
==== Windows ====
First, open a command prompt. Hit WindowsKey+R, type "cmd" in the box, then hit
enter. A black box should appear. cd
to the directory your plugins
are in, for instance, if your server was located at C:\Server\
then
you would run cd C:\Server\plugins
. Type dir
to verify
the name of the CommandHelper jar. This may be different depending on what you
named it, but you'll use whatever it's named in place of CommandHelper.jar
.
Skip ahead to the next section.
==== Linux ====
Open a terminal. Depending on your linux distribution, this will be different, but
the program is likely called "Terminal". Change to the directory your plugins are in.
For instance, if your server was located at /server/
then you would run
cd /server/plugins/
. Run ls
to verify the name of the
CommandHelper jar. This may be different depending on what you named it, but you'll
use whatever it's named in place of CommandHelper.jar
.
Skip ahead to the next section
==== Step 2 ====
Run java -jar CommandHelper.jar
from your prompt. You will see the
help listing. Each tool is it's own "verb". The syntax for running a particular
tool is java -jar CommandHelper.jar <verb> [<arguments for this tool>]
See the section below that shows the help listing for more details about each tool.
=== Tool listing ===
These are the command line tools for MethodScript. For more information about a particular mode, run the help mode with the mode you need help in as the argument. To run a command, in general, use the command: java -jar commandhelper-3.3.5-SNAPSHOT-full.jar <mode name> <[mode specific arguments]> or mscript -- <mode name> <[mode specific arguments]> if you have previously installed the command line version. Modes: (a mode must be the first argument) api: Prints documentation for the function specified, then exits. The argument is actually a regex, with ^ and $ added to it, so if you would like to search the function list, you can instead provide the rest of the regex. If multiple matches are found, the full list of matches is printed out. For instance "array.*" will return all the functions that start with the word "array". build-extension: Given a path to the git source repo, pulls down the code, builds the extension with maven, and places the artifact in the extension folder. Git, Maven, and the JDK must all be pre-installed on your system for this to work, but once those are configued and working so you can run git and mvn from the cmdline, the rest of the build system should work. check-update: Checks if an update is available from the build server. cmdline: Given a source file, runs it in cmdline mode. This is the "main" way of executing source files. cmdline-args: MethodScript requires certain arguments to be passed to the java program to properly start up. This tool prints out the arguments that it needs, in a version specific manner. Depending on your system, and the version of the program, you may get different arguments, but these will always be up to date. You can either integrate them into your startup flow manually, or dynamically call this command to automatically update it. The command may return an empty string. If so, this means that no commandline flags are needed. copyright: Prints the copyright and exits. core-functions: Prints a list of functions tagged with the @core annotation, then exits. doc-export: Outputs all known function documentation as a json. This includes known extensions as well as the built in functions. docs: Prints documentation for the functions that CommandHelper knows about, then exits. edit-prefs: Launches the prefs directory in a default text editor, or your defined editor. eval: Runs the given MethodScript code, then exits. examples: Installs one of the built in LocalPackage examples, which may in and of itself be useful, but is primarily meant to showcase various features. extension-docs: Generates markdown documentation for the specified extension utilizing its code, to be used most likely on the extensions github page. help (Aliases: /?, --help, -help, -h): Displays help for all modes, or the given mode if one is provided. help-topic: Provides information on a general topic. To see the list of topics, run with no arguments. install-cmdline: Installs MethodScript to your system, so that commandline scripts work. (Currently only unix is supported.) install-mssql-auth: Downloads the correct MSSQL JDBC Auth dll and places it in the C:\Program Files\MethodScript folder. It is required that MethodScript be generally installed first. This command is only useable on Windows. interpreter: Launches the minimal cmdline interpreter. java-version: Prints the current major java version then exits. json-api: Prints the api.json file to stdout. This takes no parameters. key-gen: Creates an ssh compatible rsa key pair. This is used with the Federation system, but is useful with other tools as well. l10n-ui: Launches the Localization (L10n) UI, which simplifies translations. lang-serv: Starts up the language server, which implements the Language Server Protocol manager: Launches the built in interactive data manager, which will allow command line access to the full persistence database. mslp: Creates an MSLP file based on the directory specified. new: Creates a blank, executable script in the specified location with the appropriate permissions, having the correct hashbang, and ready to be executed. If the specified file already exists, it will refuse to create it, unless --force is set. new-type: Creates a new type. This command should only be run at the root of a classLibrary, and given the class name, will create the appropriate folder structure (as necessary) as well as providing a default file prepopulated with a reasonable template. If the file already exists, will refuse to continue. optimizer-test: Given a source file, reads it in and outputs the "optimized" version. This is meant as a debug tool, but could be used as an obfuscation tool as well. The target environment(s) must be specified if not targetting command line. pn-viewer: Launches the Persistence Network viewer. This is a GUI tool that can help you visualize your databases. print-db: Prints out the built in database in a human readable form, then exits. profiler-summary: Analyzes the output file for a profiler session, and generates a summary report of the results. site-deploy: Deploys the documentation site, using the preferences specified in the configuration file. This mechanism completely re-writes the remote site, so that builds are totally reproduceable. syntax: Generates the syntax highlighter for the specified editor (if available). ui: Launches a GUI that provides a list of all the sub GUI tools provided, and allows selection of a module. This command creates a subshell to run the launcher in, so that the original cmdline shell returns. uninstall-cmdline: Uninstalls the MethodScript interpreter from your system. validate-l10n: (Validate 'L ten N'.) Validates the given localization database. This is important to do before submitting a PR to the localization database, otherwise the PR will be rejected. The command will print a list of errors and exit with code 1 if there are validation errors, otherwise the command will exit with exit code 0 and print nothing. verify: Compiles the given file, returning a json describing the errors in the file, or returning nothing if the file compiles cleanly. The target environment(s) must be specified if not targetting command line. version (Aliases: -v, --v, -version, --version): Prints the version of CommandHelper, and exits. webserver: Provides a controller interface for a MethodScript web server. Note that this is not meant to be used as a front facing web server, and is instead meant to be used as a backend server behind an Nginx, Apache, or other frontend web server.==== mslp ====
Creates an MSLP file based on the directory specified. Usage: [--environments <environments, ...>] <path/to/folder, ...> <path/to/folder>: The path to the folder No flags. --environments: Optional. A list. The environments to target during compilation. May be one or more of com.laytonsmith.core.environments.CommandHelperEnvironment, com.laytonsmith.core.environments.GlobalEnv, com.laytonsmith.core.environments.StaticRuntimeEnv, com.laytonsmith.core.compiler.CompilerEnvironment, or com.laytonsmith.core.asm.LLVMEnvironment, but note that com.laytonsmith.core.environments.GlobalEnv and com.laytonsmith.core.compiler.CompilerEnvironment are provided for you.==== validate-l10n ====
(Validate 'L ten N'.) Validates the given localization database. This is important to do before submitting a PR to the localization database, otherwise the PR will be rejected. The command will print a list of errors and exit with code 1 if there are validation errors, otherwise the command will exit with exit code 0 and print nothing. Usage: --database <path to folder> No flags. --database: Required. The location of the database to validate.==== docs ====
Prints documentation for the functions that CommandHelper knows about, then exits. Usage: <type, ...> <type>: The type of the documentation, defaulting to html. It may be one of the following: HTML, WIKI, TEXT, or MARKDOWN No flags.==== pn-viewer ====
Launches the Persistence Network viewer. This is a GUI tool that can help you visualize your databases. Usage: [--server] [--password <password>] [--port <#port>] Flags: --server: Sets up a server running on this machine, that can be accessed by remote Persistence Network Viewers. If this is set, you must also provide the --port and --password options. Options: --password: Optional. The password that remote clients will need to provide to connect. Leave the field blank to be prompted for a password. --port: Optional. A numeric value. The port for the server to listen on.==== api ====
Prints documentation for the function specified, then exits. The argument is actually a regex, with ^ and $ added to it, so if you would like to search the function list, you can instead provide the rest of the regex. If multiple matches are found, the full list of matches is printed out. For instance "array.*" will return all the functions that start with the word "array". Usage: [-eo] [--platform <platform> (default "INTERPRETER_JAVA")] <functionRegex> <functionRegex>: The name of the function to print the information for Flags (Short flags may be combined): -e: Also prints out the examples for the function (if any). -o: Instead of displaying the results in the console, launches the website with this function highlighted. The local documentation is guaranteed to be consistent with your local version of MethodScript, while the online results may be slightly stale, or may be from a different build, but the results are generally richer. --examples: Alias to -e --online: Alias to -o Options: --platform: Optional. The API platform to use. By default, INTERPRETER_JAVA, but may be one of INTERPRETER_JAVA, COMPILER_BASH, or COMPILER_LLVM==== cycle ====
Fully starts up the interpreter engine, and runs exit(0), which represents the engine overhead. Meant for performance testing of the engine itself. Note that the first run will install various things, which should not be compared against second startup. In general, you can time this command, with, for instance `time` on linux. Usage: No arguments. No flags or options.==== install-mssql-auth ====
Downloads the correct MSSQL JDBC Auth dll and places it in the C:\Program Files\MethodScript folder. It is required that MethodScript be generally installed first. This command is only useable on Windows. Usage: No arguments. No flags or options.==== build-extension ====
Given a path to the git source repo, pulls down the code, builds the extension with maven, and places the artifact in the extension folder. Git, Maven, and the JDK must all be pre-installed on your system for this to work, but once those are configued and working so you can run git and mvn from the cmdline, the rest of the build system should work. Usage: [-f] [-b <branch> (default "master")] [-e <dir> (default "D:\a\r1\a\_EngineHub.CommandHelper\CommandHelper-3.3.5-SNAPSHOT-20250621.1.jar\MethodScript\extensions")] -s <git repo path> Flags (Short flags may be combined): -f: If the checkout folder already exists, it is first deleted, then cloned again. --force: Alias to -f Options: -b: Optional. The branch to check out. Defaults to "master". -e: Optional. The extension directory you want to install the built artifact to, by default, this installation's extension directory. -s: Required. The path to the git repo (ending in .git usually). May be either http or ssh, this parameter is just passed through to git. --branch: Alias to -b --extension-dir: Alias to -e --source: Alias to -s==== ui ====
Launches a GUI that provides a list of all the sub GUI tools provided, and allows selection of a module. This command creates a subshell to run the launcher in, so that the original cmdline shell returns. Usage: [--in-shell] Flags: --in-shell: Runs the launcher in the same shell process. By default, it creates a new process and causes the initial shell to return. Options:==== examples ====
Installs one of the built in LocalPackage examples, which may in and of itself be useful, but is primarily meant to showcase various features. Usage: <packageName, ...> <packageName>: The name of the package to install. Leave blank to see a list of examples to choose from. No flags.==== cmdline ====
Given a source file, runs it in cmdline mode. This is the "main" way of executing source files. Usage: <file and args, ...> <file and args>: File path/arguments No flags.==== optimizer-test ====
Given a source file, reads it in and outputs the "optimized" version. This is meant as a debug tool, but could be used as an obfuscation tool as well. The target environment(s) must be specified if not targetting command line. Usage: [--environments <environments, ...>] <file, ...> <file>: File path No flags. --environments: Optional. A list. The environments to target during compilation. May be one or more of com.laytonsmith.core.environments.CommandHelperEnvironment, com.laytonsmith.core.environments.GlobalEnv, com.laytonsmith.core.environments.StaticRuntimeEnv, com.laytonsmith.core.compiler.CompilerEnvironment, or com.laytonsmith.core.asm.LLVMEnvironment, but note that com.laytonsmith.core.environments.GlobalEnv and com.laytonsmith.core.compiler.CompilerEnvironment are provided for you.==== cmdline-args ====
MethodScript requires certain arguments to be passed to the java program to properly start up. This tool prints out the arguments that it needs, in a version specific manner. Depending on your system, and the version of the program, you may get different arguments, but these will always be up to date. You can either integrate them into your startup flow manually, or dynamically call this command to automatically update it. The command may return an empty string. If so, this means that no commandline flags are needed. Usage: No arguments. No flags or options.==== lang-serv ====
Starts up the language server, which implements the Language Server Protocol Usage: [--stdio] [--host <host>] [--port <#port>] <unrecognizedArgs, ...> <unrecognizedArgs>: For future compatibility reasons, unrecognized arguments are not an error, but they are not supported unless otherwise noted. Flags: --stdio: If set, stdio is used instead of socket connections. Options: --host: Optional. The host location that the client is running on. --port: Optional. A numeric value. The port the client is running on.==== verify ====
Compiles the given file, returning a json describing the errors in the file, or returning nothing if the file compiles cleanly. The target environment(s) must be specified if not targetting command line. Usage: [--environments <environments, ...>] <file, ...> <file>: The file to check No flags. --environments: Optional. A list. The environments to target during compilation. May be one or more of com.laytonsmith.core.environments.CommandHelperEnvironment, com.laytonsmith.core.environments.GlobalEnv, com.laytonsmith.core.environments.StaticRuntimeEnv, com.laytonsmith.core.compiler.CompilerEnvironment, or com.laytonsmith.core.asm.LLVMEnvironment, but note that com.laytonsmith.core.environments.GlobalEnv and com.laytonsmith.core.compiler.CompilerEnvironment are provided for you.==== uninstall-cmdline ====
Uninstalls the MethodScript interpreter from your system. Usage: [--command <command name> (default "mscript")] No flags. --command: Optional. Specify the name of instance to be uninstalled.==== l10n-ui ====
Launches the Localization (L10n) UI, which simplifies translations. Usage: [--in-shell] [--database <path to database>] Flags: --in-shell: Runs the UI in the same shell process. By default, it creates a new process and causes the initial shell to return. Options: --database: Optional. Sets the database from the command line. If this is absent, the UI will prompt you for the location.==== asm ====
Provides the interface for compiling MethodScript to native executables. The system compiles to LLVM, and so many of the options here are just wrappers around various LLVM tools. Make sure you install the toolchain first with --install-toolchain. Usage: [-v] [--extraopt] [--install-toolchain] [--no-llvm-link] [--no-target-logging] [--noopt] [-o <output file>] [--build-mode <debug/release> (default "release")] [--build-target <build-target, ...>] [--executable-name <executable name>] <input> <input>: Provides the input file/directory. If given a folder, the directory is scanned recursively to find all the ms files, with a file at the root named "main.ms" taken to be the entry point. If given a single file, it is compiled individually, and regardless of the name, is considered to be the entry point. By default, the current directory is used. Flags (Short flags may be combined): -v: Outputs verbose information during the build process. --extraopt: Does more aggressive optimizations. This can be done for release binaries, and generally increases compile time, but in theory may make programs faster. --install-toolchain: Installs the LLVM compiler toolchain. This is not necessary if your system is already set up with the toolchain, but this will automatically install the proper toolchain for you. Run as root/Administrator. Ignores other options, and exits once installation is complete. Installation is indempotent, you may run this unconditionally, and if everything is installed correctly, nothing will happen. New updates to MethodScript may require reinstallation of the toolchain. --no-llvm-link: Compiles the files to IR without including the headers or running llvm-link, then quits. Useful for debugging the compiler, but results in potentially incomplete (and thus uncompilable) IR. No binary is generated with this option specified. --no-target-logging: Disables outputting of code target information in the LLVM IR file. --noopt: Disables optimizations. This is only useful for debugging, and should not normally be set. If this flag is set, --extraopt is ignored. --verbose: Alias to -v Options: -o: Optional. Provides the output directory where the outputs should be placed. By default, this is considered to be the directory ./target. --build-mode: Optional. Sets the build version. Can be release or debug. Debug builds tend to contain more detailed information, but note that some debug information is set in all builds. Defaults to "release", but may be "debug" instead. --build-target: Optional. A list. Overrides the default build target. By default, compilation occurs for the host currently running the build, but cross compilation is possible by setting this value. Specify the target in this option. You must first have installed the toolchain for this target, if this options is used in combination with the --install-toolchain option, it will install the toolchain for this target instead. The value should follow the format: "<arch>[<sub>]-<vendor>-<sys>[-<abi>]". Please see the associated documentation for full information on valid options. --executable-name: Optional. Sets the output name of the executable. The extension is added automatically. If a single file is provided as the input, the name is inherited from that file. Otherwise, the name is inherited by the containing folder. --output: Alias to -o==== java-version ====
Prints the current major java version then exits. Usage: No arguments. No flags or options.==== syntax ====
Generates the syntax highlighter for the specified editor (if available). Usage: <type> <type>: The type of the syntax file to generate. Don't specify a type to see the available options. No flags.==== print-db ====
Prints out the built in database in a human readable form, then exits. Usage: No arguments. No flags or options.==== site-deploy ====
Deploys the documentation site, using the preferences specified in the configuration file. This mechanism completely re-writes the remote site, so that builds are totally reproduceable. Usage: [-d] [--clear-local-cache] [--generate-prefs] [--no-progress-clear] [--use-local-cache] [-c <config file> (default "C:\Users\VssAdministrator\.mscript\site-deploy.ini")] [--override-id-rsa <id-rsa-path>] [--override-post-script <script-location>] Flags (Short flags may be combined): -d: Validates all of the uploaded web pages, and prints out a summary of the results. This uses the value defined in the config file for validation. --clear-local-cache: Clears the local cache of all entries, then exits. --do-validation: Alias to -d --generate-prefs: Generates the preferences file initially, which you can then fill in. --no-progress-clear: When set, does not clear the progress bar line. This is mostly useful when debugging the site-deploy tool itself. --use-local-cache: Generally, when the uploader runs, it checks the remote server to see if the file already exists there (and is unchanged compared to the local file). If it is unchanged, the upload is skipped. However, even checking with the remote to see what the status of the remote file is takes time. If you are the only one uploading files, then we can simply use a local cache of what the remote system has, and we can skip the step of checking with the remote server for any given file. The cache is always populated, whether or not this flag is set, so if you aren't sure if you can trust the cache, run once without this flag, then for future runs, you can be sure that the local cache is up to date. Options: -c: Optional. The path to the config file for deployment --config: Alias to -c --override-id-rsa: Optional. If the rsa key is in the non-default location, that location be specified here --override-post-script: Optional. If set, overrides the post-script value in the config.==== core-functions ====
Prints a list of functions tagged with the @core annotation, then exits. Usage: No arguments. No flags or options.==== copyright ====
Prints the copyright and exits. Usage: No arguments. No flags or options.==== manager ====
Launches the built in interactive data manager, which will allow command line access to the full persistence database. Usage: No arguments. No flags or options.==== install-cmdline ====
Installs MethodScript to your system, so that commandline scripts work. (Currently only unix is supported.) Usage: [--command <command name> (default "mscript")] No flags. --command: Optional. Sets the name of the command. This allows support for multiple installations per system.==== version ====
Prints the version of CommandHelper, and exits. Usage: No arguments. No flags or options.==== check-update ====
Checks if an update is available from the build server. By default, the command checks against the official build server, which is located at https://apps.methodscript.com/ however this can be changed to other build servers by setting the methodscript.apps.server system property. Usage: No arguments. No flags or options.==== key-gen ====
Creates an ssh compatible rsa key pair. This is used with the Federation system, but is useful with other tools as well. Usage: -l <label> -o <file> No flags. -l: Required. Label for the public key. For instance, "user@localhost" or an email address. -o: Required. Output file for the keys. For instance, "/home/user/.ssh/id_rsa". The public key will have the same name, with ".pub" appended. --label: Alias to -l --output-file: Alias to -o==== help ====
Displays help for all modes, or the given mode if one is provided. Usage: <mode name> <mode name>: Displays help for the given mode. No flags.==== profiler-summary ====
Analyzes the output file for a profiler session, and generates a summary report of the results. Usage: [-i <#ignore-percentage> (default 0)] <input-file, ...> <input-file>: Path to the profiler file to use. No flags. -i: Optional. A numeric value. This value dictates how much of the lower end data is ignored. If the function took less time than this percentage of the total time, it is omitted from the results. --ignore-percentage: Alias to -i==== new-type ====
Creates a new type. This command should only be run at the root of a classLibrary, and given the class name, will create the appropriate folder structure (as necessary) as well as providing a default file prepopulated with a reasonable template. If the file already exists, will refuse to continue. Usage: [-t <template> (default "class")] <fully qualified class name> <fully qualified class name>: The class name to create. This should be the fully qualified class name. No flags. -t: Optional. The template type to use --type: Alias to -t==== extension-docs ====
Generates markdown documentation for the specified extension utilizing its code, to be used most likely on the extensions github page. Usage: -i <path to jar file> [-o <output file name>] No flags. -i: Required. The extension jar to generate documentation for. -o: Optional. The file to output the generated documentation to. (Should probably end in .md, but is not required to.) This argument is optional, and if left off, the output will instead print to stdout. --input-jar: Alias to -i --output-file: Alias to -o==== help-topic ====
Provides information on a general topic. To see the list of topics, run with no arguments. Usage: <topic name> <topic name>: The topic to read more about. No flags.==== edit-prefs ====
Launches the prefs directory in a default text editor, or your defined editor. By default, on Windows, "code.cmd" (Visual Studio Code) is the default editor. On Linux systems, vim is default, though if $EDITOR is set, that is used, or if $VISUAL is also set, that is used instead. In all OSes, you can override the default editor with the MS_EDITOR environment variable. The prefs folder is passed as the last argument to the command. Passing in the editor to the command will bypass all these mechanisms, and use the specified editor in that one launch. Usage: [--wait] <command> <command>: Uses a different command to open the editor. This overrides the environment value (if set). Flags: --wait: Waits for the editor to finish. This is implied for some known programs, where that is necessary (vim, nano, and emacs) but may be specified manually. This is generally not necessary for GUI editors that open in a new window. Options:==== doc-export ====
Outputs all known function documentation as a json. This includes known extensions as well as the built in functions. Usage: [-o <output file>] [--extension-dir <extension folder> (default "./CommandHelper/extensions")] No flags. -o: Optional. The file to output the generated json to. If this parameter is missing, it is simply printed to screen. --extension-dir: Optional. Provides the path to your extension directory. --output-file: Alias to -o==== json-api ====
Prints the api.json file to stdout. This takes no parameters. Usage: No arguments. No flags or options.==== webserver ====
Provides a controller interface for a MethodScript web server. Note that this is not meant to be used as a front facing web server, and is instead meant to be used as a backend server behind an Nginx, Apache, or other frontend web server. In addition to providing the installer, this provides an easy way to control the webserver from the command line. This server cannot be used as a server frontend, it will only work with MethodScript files, and cannot serve static content, such as css and javascript files. It provides a special runtime environment for efficiently running behind another front facing web server, such as Nginx, Apache, or any other server that supports "reverse proxy" techniques. Usage: [--force] [--foreground] [--install] [--recompile] [--start] [--stop] Flags: --force: (Used with the --stop flag) By default, the server stops gracefully, allowing running scripts to finish, but stopping accepting new connections. If you wish to force an immediate shutdown however, you can use this flag. --foreground: (Used with the --start flag) Does not create a daemon process, and runs directly in the current shell. Note that Ctrl-C is supported in this mode, and does a non-graceful shutdown. Ctrl-D will perform a graceful shutdown. --install: Installs the webserver. This creates the config file templates, and creates other folders as needed. --recompile: Causes the webserver to discard the compiled scripts, and recompile everything. This has the same effect as restarting the process, but is quicker. --start: Starts the webserver. --stop: Stops the webserver. Options:==== interpreter ====
Launches the minimal cmdline interpreter. Usage: [--location----- <location> (default ".")] No flags. --location-----: Optional. Sets the initial working directory of the interpreter. This is optional, but is automatically set by the mscript program. The option name is strange, to avoid any conflicts with script arguments.==== eval ====
Runs the given MethodScript code, then exits. Usage: <methodscript code, ...> <methodscript code>: The code to run No flags.==== new ====
Creates a blank, executable script in the specified location with the appropriate permissions, having the correct hashbang, and ready to be executed. If the specified file already exists, it will refuse to create it, unless --force is set. Usage: [-f] <file, ...> <file>: Location and name to create the script as. Multiple arguments can be provided, and they will create multiple files. Flags (Short flags may be combined): -f: Forces the file to be overwritten, even if it already exists. --force: Alias to -f Options:
Find a bug in this page? Edit this page yourself, then submit a pull request.