diff --git a/README.md b/README.md index 42724901..c717584f 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,15 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `-r` raw output. Provides a more literal JSON output, typically with string values and no additional semantic processing - `-v` version information +### Exit Codes +Any fatal errors within `jc` will generate an exit code of `100`, otherwise the exit code will be `0`. When using the "magic" syntax (e.g. `jc ifconfig eth0`), `jc` will store the exit code of the program being parsed and add it to the `jc` exit code. This way it is easier to tell if an error was from the parsed program or `jc`. + +Consider the following examples using `ifconfig`: +- `ifconfig` exit code = `0`, `jc` exit code = `0`, combined exit code = `0` (no errors) +- `ifconfig` exit code = `1`, `jc` exit code = `0`, combined exit code = `1` (error in `ifconfig`) +- `ifconfig` exit code = `0`, `jc` exit code = `100`, combined exit code = `100` (error in `jc`) +- `ifconfig` exit code = `1`, `jc` exit code = `100`, combined exit code = `101` (error in both `ifconfig` and `jc`) + ### Setting Custom Colors via Environment Variable You can specify custom colors via the `JC_COLORS` environment variable. The `JC_COLORS` environment variable takes four comma separated string values in the following format: ```bash diff --git a/templates/readme_template b/templates/readme_template index b9758e8b..f077b5e3 100644 --- a/templates/readme_template +++ b/templates/readme_template @@ -131,6 +131,15 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio - `-r` raw output. Provides a more literal JSON output, typically with string values and no additional semantic processing - `-v` version information +### Exit Codes +Any fatal errors within `jc` will generate an exit code of `100`, otherwise the exit code will be `0`. When using the "magic" syntax (e.g. `jc ifconfig eth0`), `jc` will store the exit code of the program being parsed and add it to the `jc` exit code. This way it is easier to tell if an error was from the parsed program or `jc`. + +Consider the following examples using `ifconfig`: +- `ifconfig` exit code = `0`, `jc` exit code = `0`, combined exit code = `0` (no errors) +- `ifconfig` exit code = `1`, `jc` exit code = `0`, combined exit code = `1` (error in `ifconfig`) +- `ifconfig` exit code = `0`, `jc` exit code = `100`, combined exit code = `100` (error in `jc`) +- `ifconfig` exit code = `1`, `jc` exit code = `100`, combined exit code = `101` (error in both `ifconfig` and `jc`) + ### Setting Custom Colors via Environment Variable You can specify custom colors via the `JC_COLORS` environment variable. The `JC_COLORS` environment variable takes four comma separated string values in the following format: ```bash