How to use the command ngs (with examples)
The command ngs
is a scripting language created specifically for Ops. It provides a simple and expressive syntax for writing scripts to automate operations tasks. This article will illustrate three common use cases for the ngs
command: executing a code snippet, executing a script, and printing the version.
Use case 1: Execute a code snippet
Code:
ngs -e "echo('ngs is executed')"
Motivation:
Executing a code snippet with the ngs
command can be useful when you want to quickly test a small piece of code or perform a one-time operation without the need to create a separate script file.
Explanation:
-e
: This option specifies that the following argument is a code snippet to be executed."echo('ngs is executed')"
: This is the code snippet that will be executed. In this example, it simply prints the message “ngs is executed” to the console.
Example output:
ngs is executed
Use case 2: Execute a script
Code:
ngs path/to/script.ngs
Motivation:
Executing a script with the ngs
command is the most common use case. It allows you to run a script that contains multiple lines of code and perform more complex operations.
Explanation:
path/to/script.ngs
: This is the path to the script file that will be executed. Replacepath/to/script.ngs
with the actual path to the script file on your system.
Example output: The output will depend on the script being executed. It could be text printed to the console, files generated, or any other operation defined in the script.
Use case 3: Print the version
Code:
ngs --version
Motivation:
Printing the version of the ngs
command can be helpful when troubleshooting or verifying if the correct version of ngs
is installed on your system.
Explanation:
--version
: This option tells thengs
command to print the version information.
Example output:
ngs 1.0.0
Conclusion:
The ngs
command is a powerful tool for executing code snippets and scripts written in the NGS scripting language. By leveraging its features, you can automate operations tasks and streamline your workflow. Whether you need to quickly test a small piece of code, run complex scripts, or check the version, the ngs
command has got you covered.