diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-26 09:00:31 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-26 11:27:51 +0200 |
commit | d68ed957f785f4e6969a213e05e4a6bbfc7c391a (patch) | |
tree | 27f29481bb21112449802bd071592e8e143852f4 /jt.md | |
parent | 2288d53ce4e55e28cf8f17e3cd06cc5905b88223 (diff) | |
download | jt2-d68ed957f785f4e6969a213e05e4a6bbfc7c391a.tar.gz |
feat! rewrite code
This started out as a change to re-do the command line parsing. I
ended up rewriting everything, and failed to do it in a way that could
be rebased into a sensible series of small commits.
Diffstat (limited to 'jt.md')
-rw-r--r-- | jt.md | 112 |
1 files changed, 100 insertions, 12 deletions
@@ -23,7 +23,7 @@ journal for the user, and a new journal entry. The entry is a draft until it's finished. ~~~sh -$ jt init ~/Journal default "My private journal" +$ jt --dirname ~/Journal init default "My private journal" $ jt new --tag meta --tag journalling "My first journal entry" ... # text editor is opened so the new entry can be written $ jt finish @@ -37,20 +37,104 @@ verified using *scenarios* for the [Subplot][] tool. [Subplot]: https://subplot.liw.fi/ +## Configuration file handling + +These scenarios verify that jt handles its configuration file +correctly. + +### Shows defaults if no configuration file is present + +~~~scenario +given an installed jt +when I run jt2 config +then stdout matches regex dirname:.*/\.local.share/jt2 +then stdout matches regex editor: "/usr/bin/editor" +~~~ + +### Gives error if configuration missing file specified + +~~~scenario +given an installed jt +when I try to run jt2 --config does-not-exist config +then command fails +then stderr contains "does-not-exist" +~~~ + +### Accepts empty configuration file + +~~~scenario +given an installed jt +given file empty.yaml +when I run jt2 --config empty.yaml config +then stdout matches regex dirname:.*/\.local.share/jt2 +then stdout matches regex editor: "/usr/bin/editor" +~~~ + +~~~{#empty.yaml .file .yaml} +{} +~~~ + +### Accepts configuration file + +Note that the configuration file uses a tilde syntax to refer to the +user's home directory. + +~~~scenario +given an installed jt +given file config.yaml +when I run jt2 --config config.yaml config +then stdout matches regex dirname:.*/.*/journal +then stdout matches regex editor: "emacs" +~~~ + +~~~{#config.yaml .file .yaml} +dirname: ~/journal +editor: emacs +~~~ + +### Command line options override configuration file fields + +~~~scenario +given an installed jt +given file config.yaml +when I run jt2 --config config.yaml --dirname xxx --editor yyy config +then stdout matches regex dirname: "xxx" +then stdout matches regex editor: "yyy" +~~~ + + + +### Rejects configuration file with extra entries + +~~~scenario +given an installed jt +given file toomuch.yaml +when I try to run jt2 --config toomuch.yaml config +then command fails +then stderr contains "unknown_field" +~~~ + +~~~{#toomuch.yaml .file .yaml} +unknown_field: foo +~~~ + + ## Create a new local journal repository `jt` works on a local repository, and it can be created an initialised using the tool. ~~~scenario -when I invoke jt init jrnl default "My test journal" +given an installed jt + +when I run jt2 --dirname jrnl init default "My test journal" then command is successful and directory jrnl exists -when I invoke jt is-journal jrnl +when I run jt2 --dirname jrnl is-journal then command is successful -when I invoke jt is-journal bogus +when I try to run jt2 --dirname bogus is-journal then command fails ~~~ @@ -60,26 +144,28 @@ then command fails Verify that we can create a new draft entry for the journal. ~~~scenario -when I invoke jt init jrnl default "My test journal" +given an installed jt + +when I run jt2 --dirname jrnl init default "My test journal" then command is successful and there are no drafts in jrnl and there are no journal entries in jrnl -when I invoke jt new "Abracadabra" --editor=none --dirname=jrnl +when I run jt2 --editor=none --dirname=jrnl new "Abracadabra" then command is successful and there is one draft in jrnl and draft 0 in jrnl contains "Abracadabra" given an executable script append.sh -when I invoke jt edit --editor=./append.sh --dirname=jrnl +when I run jt2 --editor=./append.sh --dirname=jrnl edit then command is successful and draft 0 in jrnl contains "Open sesame!" -when I invoke jt finish --dirname=jrnl +when I run jt2 --dirname=jrnl finish then command is successful and there is one journal entry in jrnl, at FILE -and file <FILE> contains "Abracadabra" -and file <FILE> contains "Open sesame!" +and journal entry <FILE> contains "Abracadabra" +and journal entry <FILE> contains "Open sesame!" and there are no drafts in jrnl ~~~ @@ -97,8 +183,10 @@ author: template: python bindings: - subplot/jt.yaml -- subplot/runcmd.yaml +- subplot/vendored/files.yaml +- subplot/vendored/runcmd.yaml functions: - subplot/jt.py -- subplot/runcmd.py +- subplot/vendored/files.py +- subplot/vendored/runcmd.py ... |