From 35074ac855f654ae00a8acafe48f7ae94e215a5f Mon Sep 17 00:00:00 2001 From: t4ccer Date: Fri, 30 Aug 2024 19:05:21 -0600 Subject: [PATCH] Add `cgt-cli` doc section on filtering output --- cgt_cli/README.md | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/cgt_cli/README.md b/cgt_cli/README.md index 6db4aee..71c879e 100644 --- a/cgt_cli/README.md +++ b/cgt_cli/README.md @@ -1,12 +1,12 @@ # `cgt-cli` -`cgt-cli` is a program to run exhaustive search of Domineering positions to get their canonical forms and temperatures. +`cgt-cli` is a command line program that evaluates game positions, exhaustive and genetic searches, and transforms evaluation and search results into graphic latex figures. ## Installation ### Building from source (Recommended) -To build `cgt-cli` from source clone the repository and install [Rust toolchain](https://www.rust-lang.org/tools/install) (`rustc`, `cargo`). If you are using [Nix](https://nixos.org/) you can use `nix develop` to bootstrap the development environment for you. +To build `cgt-cli` from the source clone the repository and install [Rust toolchain](https://www.rust-lang.org/tools/install) (`rustc`, `cargo`). If you are using [Nix](https://nixos.org/) you can use `nix develop` to bootstrap the development environment for you. ```console $ git clone https://github.com/t4ccer/cgt-tools.git @@ -21,7 +21,7 @@ You will find the binary in `./target/release` directory created by `cargo`. > [!WARNING] > There is no stable version of `cgt-cli` yet and releases are published very infrequently thus it is recommended to build from source. -Once in a while when release is published, GNU/Linux and Windows pre-built binaries are published in the [releases tab](https://github.com/t4ccer/cgt-tools/releases/). GNU/Linux pre-built binaries have some problems on my system (See [Building from source](#building-from-source)), but Windows ones seems to work (confirmed with [Wine](https://www.winehq.org/)). +Once in a while when the release is published, GNU/Linux and Windows pre-built binaries are published in the [releases tab](https://github.com/t4ccer/cgt-tools/releases/). GNU/Linux pre-built binaries have some problems on my system (See [Building from source](#building-from-source)), but Windows ones seem to work (confirmed with [Wine](https://www.winehq.org/)). ## Usage @@ -31,8 +31,24 @@ Once you have `cgt-cli` you can use it to print available options. $ cgt-cli --help ``` -You can furher call `cgt-cli` with `--help` on subcommands e.g. +You can further call `cgt-cli` with `--help` on subcommands e.g. ```console $ cgt-cli snort --help ``` + +### Filtering results + +This section assumes running `cgt-cli` on unix-like system (system needs to support split between stdout and stderr and piping outputs). While `cgt-cli` compiles on Windows and Darwin (macOS) author does not run proprietary systems to check if this section applies. + +This section requires [jq](https://jqlang.github.io/jq/) to be installed. + +`cgt-cli` will output "debug" information to standard error and computer-readable JSON object to standard output. This can be used to pipe into files and reused later or pipe into other programs, like `jq`, to filter output data. + +#### Example: Get only temperature of Snort position + +```bash +# `2>/dev/null` will silent debug information +# `| jq '.temperature' --raw-output` will filter the output and strip quotes +cgt-cli snort graph --edges '0-1,1-2' --no-graphviz 2>/dev/null | jq '.temperature' +```