You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zk/tests/cmd-new.tesh

104 lines
2.9 KiB
Plaintext

$ cd new
# Print help for `zk new`
$ zk new --help
>Usage: zk new [<directory>]
>
>Create a new note in the given notebook directory.
>
>Arguments:
> [<directory>] Directory in which to create the note.
>
>Flags:
> -h, --help Show context-sensitive help.
> --notebook-dir=PATH Turn off notebook auto-discovery and set manually
> the notebook where commands are run.
> -W, --working-dir=PATH Run as if zk was started in <PATH> instead of the
> current working directory.
> --no-input Never prompt or ask for confirmation.
>
> -t, --title=TITLE Title of the new note.
> --date=DATE Set the current date.
> -g, --group=NAME Name of the config group this note belongs to.
> Takes precedence over the config of the
> directory.
> --extra=KEY=VALUE,... Extra variables passed to the templates.
> --template=PATH Custom template used to render the note.
> -p, --print-path Print the path of the created note instead of
> editing it.
> -n, --dry-run Don't actually create the note. Instead, prints
> its content on stdout and the generated path on
> stderr.
# Default note title.
$ zk new --print-path
>{{working-dir}}/untitled.md
$ cat untitled.md
># Untitled
>
>
# Provide a custom title.
$ zk new --title "Custom title" --print-path
>{{working-dir}}/custom-title.md
$ cat custom-title.md
># Custom title
>
>
# Provide a custom title (short flag).
$ zk new -t "Another custom title" -p
>{{working-dir}}/another-custom-title.md
# Opens the editor after creating a new note.
$ EDITOR="echo 'edit'" zk new --title "Edit"
>edit {{working-dir}}/edit.md
# Prints the path of newly created note instead of editing it.
$ EDITOR="echo 'edit'" zk new --title "Print path" --print-path
>{{working-dir}}/print-path.md
# Set explicitely today's date.
$ zk new --group date --date "January 2nd" --dry-run
2>{{working-dir}}/02-01.md
$ zk new --group date --date "December 24th" --dry-run
2>{{working-dir}}/24-12.md
# Dry run doesn't write the note.
$ zk new --dry-run --title "Dry run"
># Dry run
>
>
2>{{working-dir}}/dry-run.md
1$ cat dry-run.md
2>cat: dry-run.md: No such file or directory
# Dry run (short flag).
$ zk new -n --title "Dry run"
># 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"
># Piped note
>
>Content of the note
>
# Existing notes are not overwritten, but can be edited.
$ zk new --force-input n --title "Piped note"
>? piped-note.md already exists, do you want to edit this note instead? (y/N)
# Check that the content was not overwritten
$ cat piped-note.md
># Piped note
>
>Content of the note
>