Skip to content

Commit

Permalink
Update tests and docs re: zk new --interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
pkazmier committed Jul 13, 2022
1 parent a3b04da commit 78c7044
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/assets/media/new1.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/assets/media/screencast.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/note-creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ This option is available when running `zk edit --interactive`, which spawns [`fz

## Create a note with initial content

Initial content can be fed to the template through a standard input pipe, which will be expandable with the `{{content}}` [template variable](template-creation.md).
Initial content can be fed to the template through standard input using `zk new --interactive`, which will be expandable with the `{{content}}` [template variable](template-creation.md).

For example, to use the content of the macOS clipboard as the initial content you can run:

```sh
$ pbpaste | zk new
$ pbpaste | zk new --interactive
```

Alternatively, use the `--interactive` or `-i` option with `zk new` to redirect standard input to provide initial content for your note:
Alternatively, you can use the content of a file:

```sh
$ zk new --interactive < file.txt
Expand Down
2 changes: 1 addition & 1 deletion tests/cmd-new-template.tesh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $ cd new
$ mkdir "a dir"

# Test Handlebars template variables.
$ echo "Piped content" | zk new --group handlebars --title "Note title" --date "January 2nd" --dry-run "a dir"
$ echo "Piped content" | zk new --interactive --group handlebars --title "Note title" --date "January 2nd" --dry-run "a dir"
>id: {{match "[a-z0-9]{4}"}}
>title: Note title
>content: Piped content
Expand Down
4 changes: 2 additions & 2 deletions tests/cmd-new.tesh
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ $ zk new -n --title "Dry run"
2>{{working-dir}}/dry-run.md

# Pipe content in a new note.
$ echo "Content of the note" | EDITOR=cat zk new --title "Piped note"
$ echo "Content of the note" | EDITOR=cat zk new --interactive --title "Piped note"
># Piped note
>
>Content of the note
>

# Redirect file to standard input when creating a new note.
$ echo "Content of the note" > input
$ EDITOR=cat zk new --title "Note from redirected input" < input
$ EDITOR=cat zk new --interactive --title "Note from redirected input" < input
># Note from redirected input
>
>Content of the note
Expand Down
2 changes: 1 addition & 1 deletion tests/config-note-filename.tesh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ zk new --title "A new note" --date "January 5th" --dry-run
# Test the filename Handlebars variables.
$ mkdir "a dir"
$ echo "[note]\n filename = '\{{title}},\{{content}},\{{date now \"%m-%d\"}},\{{json extra}}'" > .zk/config.toml
$ echo "Piped content" | zk new --title "A new note" --date "January 5th" --extra key=value --dry-run
$ echo "Piped content" | zk new --interactive --title "A new note" --date "January 5th" --extra key=value --dry-run
2>{{working-dir}}/A new note,Piped content
2>,01-05,{"key":"value"}.md
$ echo "[note]\n filename = '\{{id}},\{{dir}},\{{json extra}},\{{env.ZK_NOTEBOOK_DIR}}'" > .zk/config.toml
Expand Down

0 comments on commit 78c7044

Please sign in to comment.