Merge pull request #1041 from tchak/docs-compact-default

document compact and default
This commit is contained in:
Jonathan Turner 2019-12-01 09:01:50 -08:00 committed by GitHub
commit 8d01b019f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 0 deletions

34
docs/commands/compact.md Normal file
View File

@ -0,0 +1,34 @@
# compact
This command allows us to filters out rows with empty columns. Other commands are capable of feeding `compact` with their output through pipelines.
## Usage
```shell
> [input-command] | compact [column-name]
```
## Examples
Let's say we have a table like this:
```shell
> open contacts.json
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
# │ name │ email
───┼──────────┼──────────────────
0 │ paul │ paul@example.com
1 │ andres │
2 │ jonathan │
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
```
`compact` allows us to filter out rows with empty `email` column:
```shell
> open contacts.json | compact email
━━━━━━┯━━━━━━━━━━━━━━━━━━
name │ email
──────┼──────────────────
paul │ paul@example.com
━━━━━━┷━━━━━━━━━━━━━━━━━━
```

36
docs/commands/default.md Normal file
View File

@ -0,0 +1,36 @@
# default
This command sets a default row's column if missing. Other commands are capable of feeding `default` with their output through pipelines.
## Usage
```shell
> [input-command] | default [column-name] [column-value]
```
## Examples
Let's say we have a table like this:
```shell
> open contacts.json
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━
# │ name │ email
───┼──────────┼──────────────────
0 │ paul │ paul@example.com
1 │ andres │
2 │ jonathan │
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━
```
`default` allows us to fill `email` column with a default value:
```shell
> open contacts.json | default email "no-reply@example.com"
━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━
# │ name │ email
───┼──────────┼──────────────────────
0 │ paul │ paul@example.com
1 │ andres │ no-reply@example.com
2 │ jonathan │ no-reply@example.com
━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━
```