1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/templates/manpage_template

151 lines
4.4 KiB
Plaintext
Raw Normal View History

2021-04-02 17:40:09 -07:00
.TH jc 1 {{ today }} {{ jc.version}} "JSON CLI output utility"
.SH NAME
jc \- JSONifies the output of many CLI tools and file-types
.SH SYNOPSIS
COMMAND | jc PARSER [OPTIONS]
2021-04-04 14:29:37 -07:00
or magic syntax:
jc [OPTIONS] COMMAND
2021-04-02 17:40:09 -07:00
.SH DESCRIPTION
2021-04-04 14:29:37 -07:00
jc JSONifies the output of many CLI tools and file-types for easier parsing in scripts. jc accepts piped input from \fBSTDIN\fP and outputs a JSON representation of the previous command's output to \fBSTDOUT\fP. Alternatively, the "magic" syntax can be used by prepending jc to the command to be converted. Options can be passed to jc immediately before the command is given. (Note: command aliases are not supported).
2021-04-02 17:40:09 -07:00
.SH OPTIONS
.B
Parsers:
.RS
{% for parser in jc.parsers %}
.TP
.B
\fB{{ parser.argument }}\fP
{{ parser.description }}
{% endfor %}
.RE
.PP
.B
Options:
.RS
.TP
.B
\fB-a\fP
2021-04-06 11:36:10 -07:00
about jc (JSON output)
2021-04-02 17:40:09 -07:00
.TP
.B
\fB-d\fP
debug - show traceback (\fB-dd\fP for verbose traceback)
.TP
.B
2021-04-02 18:08:46 -07:00
\fB-h\fP
2021-04-16 08:46:20 -07:00
help (\fB-h --parser_name\fP for parser documentation)
2021-04-02 18:08:46 -07:00
.TP
.B
2021-04-02 17:40:09 -07:00
\fB-m\fP
monochrome output
.TP
.B
\fB-p\fP
pretty print output
.TP
.B
\fB-q\fP
quiet - suppress warnings
.TP
.B
\fB-r\fP
raw JSON output
2021-04-02 18:08:46 -07:00
.TP
.B
\fB-v\fP
version information
2021-04-04 14:29:37 -07:00
2021-05-11 11:11:17 -07:00
.SH 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`:
.RS
`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`)
.RE
2021-04-04 14:29:37 -07:00
.SH ENVIRONMENT
You can specify custom colors via the \fBJC_COLORS\fP environment variable. The \fBJC_COLORS\fP environment variable takes four comma separated string values in the following format:
JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
Where colors are: \fBblack\fP, \fBred\fP, \fBgreen\fP, \fByellow\fP, \fBblue\fP, \fBmagenta\fP, \fBcyan\fP, \fBgray\fP, \fBbrightblack\fP, \fBbrightred\fP, \fBbrightgreen\fP, \fBbrightyellow\fP, \fBbrightblue\fP, \fBbrightmagenta\fP, \fBbrightcyan\fP, \fBwhite\fP, or \fBdefault\fP
For example, to set to the default colors:
2021-04-04 14:40:22 -07:00
.RS
2021-04-04 14:29:37 -07:00
JC_COLORS=blue,brightblack,magenta,green
or
JC_COLORS=default,default,default,default
2021-04-04 14:40:22 -07:00
.RE
2021-04-04 14:29:37 -07:00
.SH CUSTOM PARSERS
Custom local parser plugins may be placed in a \fBjc/jcparsers\fP folder in your local "App data directory":
2021-04-04 14:40:22 -07:00
.RS
2021-04-04 14:29:37 -07:00
- Linux/unix: \fB$HOME/.local/share/jc/jcparsers\fP
- macOS: \fB$HOME/Library/Application Support/jc/jcparsers\fP
2021-04-04 14:40:22 -07:00
- Windows: \fB$LOCALAPPDATA\\jc\\jc\\jcparsers\fP
.RE
2021-04-04 14:29:37 -07:00
Local parser plugins are standard python module files. Use the \fBjc/parsers/foo.py\fP parser as a template and simply place a \fB.py\fP file in the \fBjcparsers\fP subfolder.
Local plugin filenames must be valid python module names, therefore must consist entirely of alphanumerics and start with a letter. Local plugins may override default plugins.
Note: The application data directory follows the XDG Base Directory Specification
2021-04-25 20:55:43 -07:00
.SH CAVEATS
\fBLocale:\fP For best results set the \fBLANG\fP locale environment variable to \fBC\fP. For example, either by setting directly on the command-line:
\fB$ LANG=C date | jc --date\fP
or by exporting to the environment before running commands:
\fB$ export LANG=C\fP
\fBTimezones:\fP Some parsers have calculated epoch timestamp fields added to the output. Unless a timestamp field name has a \fB_utc\fP suffix it is considered naive. (i.e. based on the local timezone of the system the \fBjc\fP parser was run on).
If a UTC timezone can be detected in the text of the command output, the timestamp will be timezone aware and have a \fB_utc\fP suffix on the key name. (e.g. \fBepoch_utc\fP) No other timezones are supported for aware timestamps.
2021-04-16 08:46:20 -07:00
.SH EXAMPLES
Standard Syntax:
.RS
$ dig www.google.com | jc \fB--dig\fP \fB-p\fP
.RE
2021-04-04 14:40:22 -07:00
2021-04-16 08:46:20 -07:00
Magic Syntax:
.RS
$ jc \fB-p\fP dig www.google.com
.RE
For parser documentation:
2021-04-16 08:46:20 -07:00
.RS
$ jc \fB-h\fP \fB--dig\fP
.RE
2021-04-04 14:40:22 -07:00
.SH AUTHOR
{{ jc.author }} ({{ jc.author_email }})
2021-04-04 14:40:22 -07:00
{{ jc.website }}
2021-04-04 14:40:22 -07:00
.SH COPYRIGHT
Copyright (c) {{ jc.copyright[2:] }}
2021-04-04 14:40:22 -07:00
License: {{ jc.license }}