-
Notifications
You must be signed in to change notification settings - Fork 41
Use Cases
Before understanding use cases, it's useful to know what NGS is.
Next Generation Shell is a powerful programming language and a shell designed specifically for Ops. Because you deserve better.
Got some JSON from an API/CLI call and want to do something with it? Maybe extract something? Maybe modify a bit and shove it into next API call? That's the "data manipulation" use case. Read on.
NGS can be used both as just another tool in your my_prog1 | ngs ... | my_prog2
pipe and as standalone script.
Since NGS is a full-blown programming language, various manipulations can be easily performed. NGS has rich and consistent list of types and methods for data manipulation out of the box. Common manipulations include (with examples):
- Extracting data (public ip of all instances)
- Filtering data (all instances having specific tag and instance type)
- Mapping of data (each instance as a string of
env
androle
tags concatenated along with public ip) - Handling of missing values in data (for a report, missing public ip is displayed as
-
) - Checking whether some or all elements fulfill given condition (are all numbers above 10?)
Typical flow is to get data into NGS, process it and output the result.
See Data Manipulation Use Case for more information and examples.
WIP
You have written some command line tools. Maybe you have unit tests, maybe you don't. Now you would like to test the CLI. NGS can help with this.
In Beame, we are using NGS to test our command line tools. The testing (mini-) framework that NGS has is not a unit tests framework. The command line tools that we are testing do manage state. Therefore, our tests run in a simple top-to-bottom manner, stopping at first failure/exception.
See CLI Tools Testing Use Case for more information and examples.
WIP
If you are about to write another typical Ops script (meaning it does one or more of the following), this section is for you. There are several types of tasks which are typical for Ops. NGS has dedicated facilities, methods and syntax that covers these tasks.
- Assembles command line arguments in a non-trivial way in order to run external process with these arguments.
- Runs a process, possibly with I/O redirection.
- Runs a process, communicates with it somehow and then kills it.
- Runs a process, parses the output and processes the parsed data.
- Prints a table in a human-readable format.
- Prints out debug information that you would like to switch with environment variable (debug on / debug off).
- Prints status messages which convey current situation but which are irrelevant the next minute.
- Prints timestamped log.
- Does parallel processing such as connect to all servers and collect the output of a shell command.
TODO describe:
- External processes
- Syntax for running external processes
- Options
- Controlling external process with
p=$(...&); p.kill()
-
Argv
facility - prepare command line arguments conveniently before calling external program. Did not see any other language doing this out of the box or even a library. - Exit codes - smart handling and exceptions. Did not see any other language doing this out of the box.
- Syntax for running external processes
- AWS CLI
- Command line arguments matching into
main()
parameters - ENV
- Includes clear exception
- Exit status of NGS expression or script - convenient way to
-
exit()
defaults to error exit code Terminal
debug()
status()
log()
Table
pmap
WIP
This section describes in which cases NGS might be used today but these areas still need a lot of work.
- AWS library
- Easier scripting
- Modeling a process
- Easily integrate with existing resources
- Replicate Your Infrastructure
WIP
This section describes in which cases NGS will be a good fit in the future if everything works according to plan.
- Interactive shell for Ops tasks - design document
- Manage multiple remote VMs - design document
- FFI for using C libraries - design document
- Unified Data Model for easy manipulation of external resources through API calls and running command line tools - design document
- Use NGS instead of
make
- design document - Swiss army knife for handling tables in command line - design document
NGS official website is at https://ngs-lang.org/