Commit Graph

5904 Commits

Author SHA1 Message Date
Matthias Beyer 8d0ae1058e Make code more functional by more function chaining
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-07 13:51:42 +01:00
Matthias Beyer 07cbecc1ba Make code more functional by more function chaining.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-07 13:51:28 +01:00
Matthias Beyer d8a6e9ca9a Rewrite iteration without collecting inbetween
Because why not?

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-07 12:48:35 +01:00
Matthias Beyer 8e1768b424 Refactor code to be more idomatic
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-07 11:52:31 +01:00
Matthias Beyer ecf4cead93 Merge branch 'runtime-io-story'
This merge introduces the new runtime IO system, finally!

Now, piping imag commands into eachother as well as using standard unix
tools for piping is possible! Awesome!

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 21:26:56 +01:00
Matthias Beyer 345970d36b Import new dependencies
Because of the changes in the "src/ui.rs" files in the binary
implementations, we have new dependencies we need to import into the
build-script of the "imag" command, so that it can build the
commandline.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:35:18 +01:00
Matthias Beyer f6483f54db Add ID reporting in imag-timetrack 2018-11-06 20:35:18 +01:00
Matthias Beyer be56f9fe75 Add ID reporting in imag-mail 2018-11-06 20:35:18 +01:00
Matthias Beyer f20298cbe8 Add ID reporting in imag-store 2018-11-06 20:35:18 +01:00
Matthias Beyer c616a5cfaf Add ID reporting in imag-ref 2018-11-06 20:35:18 +01:00
Matthias Beyer 502cdf5721 Add ID reporting in imag-habit 2018-11-06 20:35:18 +01:00
Matthias Beyer 96ad41ea4c Add ID reporting in imag-mv 2018-11-06 20:35:18 +01:00
Matthias Beyer f3a03efd5d Add ID reporting in imag-wiki
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:35:18 +01:00
Matthias Beyer 029a3c448e Change WikiStore::create_wiki() interface
to also return the index page. This way a user of the library can use
the index page entry right away.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:35:18 +01:00
Matthias Beyer 860c58cbdf Add ID reporting in imag-log 2018-11-06 20:35:18 +01:00
Matthias Beyer eceae358f8 Add ID reporting in imag-notes 2018-11-06 20:35:18 +01:00
Matthias Beyer 2ca6be8322 Add id reporting in imag-diary 2018-11-06 20:35:18 +01:00
Matthias Beyer 8523ae2120 Add id reporting in imag-contact 2018-11-06 20:34:46 +01:00
Matthias Beyer 344aae5f92 Add ID reporting in imag-bookmark 2018-11-06 20:33:30 +01:00
Matthias Beyer d1f087eb57 Change libimag{bookmark, entrylink} external linking
...to report newly created entries, so that we can re-use these new
entries in the library-using code (for example for ID reporting).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:33:30 +01:00
Matthias Beyer 1e6d58bf4c Add ID reporting in imag-view 2018-11-06 20:33:30 +01:00
Matthias Beyer d3400167df Add ID reporting in imag-tag 2018-11-06 20:33:30 +01:00
Matthias Beyer aef969f8bb Add ID reporting in imag-link 2018-11-06 20:33:30 +01:00
Matthias Beyer 4e5315b0e5 Add ID reporting in imag-grep 2018-11-06 20:33:30 +01:00
Matthias Beyer ff809a3750 Add ID reporting in imag-gps 2018-11-06 20:33:30 +01:00
Matthias Beyer 3a6443b3ef Add ID reporting in imag-ids
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:33:30 +01:00
Matthias Beyer 274811243f Move imag-view to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer f83d72033f Move imag-tag to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer 527e0310ae Move imag-link to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer 4856541f5a Move imag-gps to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer 70014e04b1 Move imag-ids to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer a805db2a88 Move imag-edit to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer 30036d5628 Move imag-category to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer 01de94a387 Move imag-annotate to ID provider infrastructure 2018-11-06 20:33:30 +01:00
Matthias Beyer c1c74973e3 Implement ID providing in libimagrt
With this patch, IDs can be fetched from the CLI via libimagrt. This
gives us the possibility to automatically handle "stdin provides IDs" in
libimagrt with less boilerplate in the binaries codebases.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:33:30 +01:00
Matthias Beyer db4e83f18f Implement ID reporting
This patch adds the id reporting feature to libimagrt::runtime::Runtime,
where processed ("touched") ids can be reported to the Runtime and then
get printed to stdout if stdout is a pipe.

Other output is automatically redirected to stderr if stdout is a pipe
now.
2018-11-06 20:33:00 +01:00
Matthias Beyer 8552843796 doc: Add note on IO conventions 2018-11-06 20:32:34 +01:00
Matthias Beyer 8c597d2c4d doc: Document new IO story with libimagrt 2018-11-06 20:32:34 +01:00
Matthias Beyer 7fd3350146 Merge branch 'minor'
This merges some important fixes:

* libimagstore: Remove calls to filesystem-accessing functions but use
  abstractions instead.
* Make Debug for FileLockEntry more verbose
* Fix In-Memory test backend bug where the backend did not remove the
  old entry on "move"

as well as some nice formatting stuff and refactorings to simplify code
and similar improvements.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:25:15 +01:00
Matthias Beyer 44495d6efe Fix: Do not ignore errors in config anymore
The function already returns `Result<_>`, the only thing that had to be
done was refactoring the code for actually returning an error in that
case.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:04:47 +01:00
Matthias Beyer feea57679d Remove scope
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:04:47 +01:00
Matthias Beyer 21d411f57b Remove call to format_err!(), use err_msg() instead
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:04:47 +01:00
Matthias Beyer 09f0968755 Remove repetitive code by abstracting it
With this patch, the log level aggregation is abstracted away by using
zero sized types and a macro to implement the whole thing.

This does not alter functionality, but makes the code more readable.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 19:39:41 +01:00
Matthias Beyer 1ff1d85428 Remove unnecessary scope
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 19:08:00 +01:00
Matthias Beyer 1a70c523dc Remove indirection
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 19:03:19 +01:00
Matthias Beyer d493b04555 Remove scope for better readability
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 19:03:10 +01:00
Matthias Beyer 0e4cb59772 Format code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 19:02:57 +01:00
Matthias Beyer 582fd10acb FS backend: Safe allocation of new PathBuf object
::stf::fs::create_dir_all() takes any ref to `Path`, which is what we
have here, so we can leave out the allocation of a new PathBuf object
here.

Also remove the match by a `if let Some(_)`, which increases the
readability a bit.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 18:37:53 +01:00
Matthias Beyer 88a4eee087 Adapt Store::get()/Store::create() to check cache before FS
With this change, the cache is tested before accessing the filesystem,
which probably increases the speed if the cache has the entry, because
we avoid the slow IO operation.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 18:35:17 +01:00
Matthias Beyer becfcd4180 Fix: In-Memory test backend: Actually remove the old entry on "move"
This fixes a really ugly bug where the in-memory backend for the store
did not remove the entry from the in-memory hashmap on "move", but
simply copied it from the old location to the new one.

That caused tests to fail after the fixes introduced for the
Store::get() function which checked the filesystem and the internal
cache whether an entry exists before the actual "get" operation, because
an old entry would still exist after a move (only in the testcases).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Fixes: 09e8619cf5 ("libimagstore: Move from error-chain to failure")
2018-11-06 18:34:33 +01:00