Usage

Pnyx CMD comes in 2 formats: YAML and C# scripts. When Pnyx is ported to other platforms / languages, then those will be available from the CMD. Plans are for Python, Java, Javascript, and others. The YAML format is language independent and will be supported on all platforms.

  • To use Pnyx with YAML, use the pnxy executable.
  • To use Pnyx with C# script, use the pncs executable.

Pnyx

pnyx reads a YAML array of commands and executes them. By default, pnyx reads the commands from a YAML file. pnyx parses YAML content and expects an array of mappings. Each mapping represents a method on the Pnyx fluent library. See the Library documentation for a full list of methods available. YAML is a very flexible format, but has a steep learning curve compared to other formats (like JSON). It is recommended to learn the basics well before writing Pnyx files (good YAMLTutorial).

For example:
pnyx my.yaml.pnyx
Listing of my.yaml.pnyx: (download sample)
- readString: ax,bx,cx,dx
- sed: ['x','y','ig']
- parseCsv:
- print: $4|$3|$2|$1
Which outputs:
dy|cy|by|ay
For simple commands or quick tests, use pnyx with the inline flag (-i, --inline) to embed YAML as a parameter. The previous example could be written as:
pnyx -i "[{readString: 'ax,bx,cx,dx'},{sed: ['x','y','ig']},{parseCsv: },{print: $4|$3|$2|$1}]"

Pncs

pncs reads a C# script and executes it. By default, pncs reads the C# scripts from a file. pncs uses the Roslyn compiler with a Pnyx object set as the global object, which allows method calls directly from the fluent library.

For example:
pnyx my.cs.pncs
Listing of my.cs.pncs: (download sample)
readString("ax,bx,cx,dx");
sed("x","y","ig");
parseCsv();
print("$4|$3|$2|$1");
Which outputs:
dy|cy|by|ay
For simple commands or quick tests, use pncs with the inline flag (-i, --inline) to embed C# script as a parameter. The previous example could be written as:
pncs -i 'readString("ax,bx,cx,dx");sed("x","y","ig");parseCsv();print("$4|$3|$2|$1");'

Performance

When running either version of pnyx.cmd, the performance of processing the files are identical. However, the initial parsing of YAML files will be much faster than parsing C# scripts. Since the Roslyn compiler is used by this project, the parsing performance is outside of the scope of pnyx. You may notice a delay when running pncs, typically around a second or two.