Skip to content

Use Cases

Ilya Sher edited this page May 25, 2019 · 5 revisions

NGS 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.

Use Case: Data Manipulation

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 and role 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.

Use Case: Testing Command Line Tools


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.

Use Case: Ops Scripting


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.
  • 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 NGS Use Cases


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

Future NGS Use Cases


This section describes in which cases NGS will be a good fit in the future if everything works according to plan.