Skip to content

Commit

Permalink
Update the docs
Browse files Browse the repository at this point in the history
Fixes #40
  • Loading branch information
Arnau478 committed Jul 2, 2024
1 parent 913afab commit e79e11a
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 56 deletions.
76 changes: 47 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,60 @@ The command should be used as `hevi <file> [flags]`. The flags are described [be
The `NO_COLOR` variable is supported, and disables color (see <https://no-color.org/>) printing. Note that it can be overwritten by an explicit `--color`.

### Config file
You can create a config file and specify the default values for the flags. It follows the `.json` syntax. Example:
```json
{
"color": true,
"uppercase": true,
"show_size": false,
"show_offset": true,
"show_ascii": false,
"skip_lines": true,
"parser": "data",
"palette": {
"normal": { "base": "yellow", "dim": false },
"normal_alt": { "base": "yellow", "dim": true },
"c1": { "base": "red", "dim": false },
"c1_alt": { "base": "red", "dim": true },
"c2": { "base": "green", "dim": false },
"c2_alt": { "base": "green", "dim": true },
"c3": { "base": "blue", "dim": false },
"c3_alt": { "base": "blue", "dim": true },
"c4": { "base": "magenta", "dim": false },
"c4_alt": { "base": "magenta", "dim": true },
"c5": { "base": "cyan", "dim": false },
"c5_alt": { "base": "cyan", "dim": true }
}
}
The config file is a [ziggy](ziggy-lang.io) file. The following fields are
available:
```zig
color: bool,
uppercase: bool,
show_size: bool,
show_offset: bool,
show_ascii: bool,
skip_lines: bool,
raw: bool,
palette: Palette,
```
**Note**: for the `palette` field you must specify all palettes!

All fields are optional.

**Note**: for the `palette` field you must specify all styles!

#### Example config
```zig
.color = true,
.skip_lines = false,
.palette = Palette{
.normal = @color("yellow"),
.normal_alt = @color("yellow::dim"),
.normal_accent = @color("yellow:bright_black:bold"),
.c1 = @color("red"),
.c1_alt = @color("red::dim"),
.c1_accent = @color("red:bright_black:bold"),
.c2 = @color("green"),
.c2_alt = @color("green::dim"),
.c2_accent = @color("green:bright_black:bold"),
.c3 = @color("blue"),
.c3_alt = @color("blue::dim"),
.c3_accent = @color("blue:bright_black:bold"),
.c4 = @color("cyan"),
.c4_alt = @color("cyan::dim"),
.c4_accent = @color("cyan:bright_black:bold"),
.c5 = @color("magenta"),
.c5_alt = @color("magenta::dim"),
.c5_accent = @color("magenta:bright_black:bold"),
},
```

#### Location

The config file is located at:
| OS | Path |
| -------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Linux, MacOS, FreeBSD, OpenBSD, NetBSD | `$XDG_CONFIG_HOME/hevi/config.json` or if the env doesn't exist `$HOME/.config/hevi/config.json` |
| Windows | `%APPDATA%/hevi/config.json` |
| Linux, MacOS, FreeBSD, OpenBSD, NetBSD | `$XDG_CONFIG_HOME/hevi/config.ziggy` or if the env doesn't exist `$HOME/.config/hevi/config.ziggy` |
| Windows | `%APPDATA%/hevi/config.ziggy` |
| Other | Not supported. No config file will be read |

**Note**: hevi has a precedence for configuration and is:
#### Precedence
Hevi has a precedence for configuration and it is:
1. Flags
2. Environment variables
3. Config file
Expand Down
80 changes: 53 additions & 27 deletions doc/hevi.5.man
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
hevi configuration file

.SH SYNOPSIS
.I ~/.config/hevi/config.json
.I ~/.config/hevi/config.ziggy

.SH DESCRIPTION
This page explains how the configuration file is structured and what its fields are.

The configuration file is a JSON file.
The configuration file is a ziggy file.

These are the fields of the configuration file:
.in +4
Expand All @@ -20,45 +20,71 @@ show_offset: \fItrue\fR|\fIfalse\fR
show_ascii: \fItrue\fR|\fIfalse\fR
skip_lines: \fItrue\fR|\fIfalse\fR
raw: \fItrue\fR|\fIfalse\fR
parser: "\fIspecific parser\fR"
palette: {\fIpalettes\fR}
palette: Palette{\fIpalettes\fR}
.fi
.in

\fBNote\fR: for the \fIpalette\fR field you must specify all palettes!
The palette is a series of mappings from style names to colors. The styles are:
.in +4
.nf
normal
normal_alt
normal_accent
c1
c1_alt
c1_accent
c2
c2_alt
c2_accent
c3
c3_alt
c3_accent
c4
c4_alt
c4_accent
c5
c5_alt
c5_accent
.fi
.in

A color is specified either as \fB@color("foreground")\fR or \fB@color("foreground:background")\fR. Attributes (either \fBdim\fR or \fBbold\fR) can be added like \fB@color("foreground::attr")\fR or \fB@color("foreground:background:attr")\fR.

You can also not put all the fields in the file, default values will be chosen.
\fBNote\fR: for the \fIpalette\fR field you must specify all styles!

The config file is located at:
.in +4
.nf
\fBLinux\fR, \fBMacOS\fR, \fBFreeBSD\fR, \fBOpenBSD\fR, \fBNetBSD\fR --> \fI$XDG_CONFIG_HOME/hevi/config.json\fR or if the env doesn't exist \fI$HOME/.config/hevi/config.json\fR
\fBWindows\fR --> \fI%APPDATA%/hevi/config.json\fR
\fBLinux\fR, \fBMacOS\fR, \fBFreeBSD\fR, \fBOpenBSD\fR, \fBNetBSD\fR --> \fI$XDG_CONFIG_HOME/hevi/config.ziggy\fR or if the env doesn't exist \fI$HOME/.config/hevi/config.ziggy\fR
\fBWindows\fR --> \fI%APPDATA%/hevi/config.ziggy\fR
\fBOther\fR --> Not supported. No config file will be read.
.in

.SH EXAMPLES
.in +4
.EX
{
"color": true,
"skip_lines": false,
"parser": "data",
"palette": {
"normal": { "base": "yellow", "dim": false },
"normal_alt": { "base": "yellow", "dim": true },
"c1": { "base": "red", "dim": false },
"c1_alt": { "base": "red", "dim": true },
"c2": { "base": "green", "dim": false },
"c2_alt": { "base": "green", "dim": true },
"c3": { "base": "blue", "dim": false },
"c3_alt": { "base": "blue", "dim": true },
"c4": { "base": "magenta", "dim": false },
"c4_alt": { "base": "magenta", "dim": true },
"c5": { "base": "cyan", "dim": false },
"c5_alt": { "base": "cyan", "dim": true }
}
}
.color = true,
.skip_lines = false,
.palette = Palette{
.normal = @color("yellow"),
.normal_alt = @color("yellow::dim"),
.normal_accent = @color("yellow:bright_black:bold"),
.c1 = @color("red"),
.c1_alt = @color("red::dim"),
.c1_accent = @color("red:bright_black:bold"),
.c2 = @color("green"),
.c2_alt = @color("green::dim"),
.c2_accent = @color("green:bright_black:bold"),
.c3 = @color("blue"),
.c3_alt = @color("blue::dim"),
.c3_accent = @color("blue:bright_black:bold"),
.c4 = @color("cyan"),
.c4_alt = @color("cyan::dim"),
.c4_accent = @color("cyan:bright_black:bold"),
.c5 = @color("magenta"),
.c5_alt = @color("magenta::dim"),
.c5_accent = @color("magenta:bright_black:bold"),
},
.EE
.in

Expand Down

0 comments on commit e79e11a

Please sign in to comment.