Commit graph

511 commits

Author SHA1 Message Date
5d9fd7ab10 Simplify error handling by using linking feature of error-chain 2018-03-12 19:21:48 +01:00
e8ae2fb73e Add type so that we can serialize a Vcard 2018-03-12 17:45:50 +01:00
bbd0570013
Merge pull request #1334 from matthiasbeyer/libimagcontact/ref-from-uid
Change ref creation to use UID from vcard object
2018-03-12 17:06:54 +01:00
6803d66e87
Merge pull request #1324 from matthiasbeyer/minor
Minor patches
2018-03-12 15:23:12 +01:00
65d558727e Change ref creation to use UID from vcard object 2018-03-12 14:43:02 +01:00
252046583a
Merge pull request #1332 from matthiasbeyer/libimagcontact/all-contacts
Implement ContactStore::all_contacts()
2018-03-12 14:17:54 +01:00
68ace5d147 Fix typo 2018-03-12 13:32:23 +01:00
8a9b2e9a8f Fix: use Path::file_stem() instead of Path::file_name()
Because we don't want to know the extension of the filename here.
2018-03-12 13:30:31 +01:00
3bf1b6ccec Implement ContactStore::all_contacts() 2018-03-12 12:52:24 +01:00
d3b38b5a90
Merge pull request #1330 from matthiasbeyer/libimagrt/pipe-magic
Implement pipe magic in libimagrt
2018-03-10 16:20:36 +01:00
ce0bd9298a Implement pipe magic in libimagrt
When we merged the changes in libimagrt so that it automatically detects
whether stdin/stdout is a TTY and provides the user with stderr in case
stdout is not a TTY, we forgot that things like

    imag foo | grep bar

becomes impossible with that, because imag detects that stdout is not a
tty and automatically uses stderr for output.

But in this case, we don't want that. The output has to be stdout in
this case.

With this change, we have a flag in the runtime ("--pipe-magic" or "-P",
globally available) which turns on "pipe magic".

The expected behaviour is the following, if "-P" is passed:

* If stdout is a TTY, we print to stdout
* If stdout is not a TTY, we print to stderr
* If stdin is not a TTY, we do not provide it

If "-P" is not passed, we allow the user of libimagrt to use stdin for
interactive stuff (the interactive stuff is not yet implemented).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-03-10 15:43:44 +01:00
da408b9e67 This fixes the file parsing (again)
Unfortunately, our latest fix to file parsing did not solve all issues.
So we have to fix it _again_.

The problem was the `std::str::Lines` iterator, which apparently fails
this:

    assert_eq!(1, "".lines().count());

as an empty line seems not to be a line.

Because of that, when reading a file with an empty line at its bottom
got stripped off that line.

This patch removes the use of the `lines()` iterator and uses
`split("\n")` instead. This only works on Unix operating systems, but as
we only target unix operating systems with imag, this is not considered
an issue right now.

This patch also adds extensive tests on multiple levels in the
`libimagstore` implementation:

* On the parsing level, for the function which implements the parsing
* On the filesystem abstraction levels
* On the `Store` levels

to make sure that everything is parsed correctly.
2018-03-10 14:53:15 +01:00
579c00b62a Replace hard coded version strings with compiletime env 2018-03-06 12:45:41 +01:00
3cb7372b67 Provide LockedOutputProxy which holds locked variants of Stdout/Stderr 2018-03-04 15:42:00 +01:00
0b593d6635 Let the OutputProxy hold Stdout/Stderr objects, so we do not have to aquire them each write!() 2018-03-04 15:41:32 +01:00
19e9dfe33c Implement proxy object where runtime configures output
This is another approach for providing access to stdin/out/err via
libimagrt::runtime::Runtime.

The Runtime object does configure which output gets returned (stdout if
stdout is a tty, else stderr).

With this we can change libimagrt to read/write the store from/to
stdin/stdout without the user noticing that she does not write to stdout
but stderr.
Reading from stdin is not possible then, though.
2018-03-04 13:57:44 +01:00
c18c0bbbe4 Provide stdin/out/err resources via Runtime object
This way we can control whether "out" output goes to stdout or stderr
without the user of the functionality knowing.

This is useful for later when we use libimagrt to automatically
read and write the store from and to stdout/in depending on whether we
are talking to a TTY or a pipe.
2018-03-04 13:57:02 +01:00
f88884c321
Merge pull request #1321 from matthiasbeyer/libimagdiary/not-on-retrieve-for-module
libimagdiary: Do not rely on Store::retrieve_for_module
2018-03-03 13:53:18 +01:00
c9af23f663
Merge pull request #1314 from matthiasbeyer/imag/do-not-instantiate-runtime
Change "imag" impl to not instantiate Runtime object
2018-03-02 23:28:10 +01:00
ee5a17790f Fix multi-line reading
Reading entries with multiple entries caused all lines to be read as one
line.

This bug is fixed with this patch.
2018-03-02 21:48:17 +01:00
87d6f1221f Add testcase for reading multiple lines 2018-03-02 21:48:13 +01:00
8c37fb865a Rebuild DiaryEntryIterator to be based on StoreIdIterator
This patch rebuilds DiaryEntryIterator to be a wrapper around
StoreIdIterator and thus `Diary::entries()` to use `Store::entries` and
not `Store::retrieve_for_module()`.

The `Store::retrieve_for_module()` function is somehow buggy and loads
contents of the files into memory and _somehow_ causes the entries to be
rewritten without newlines.

This bug is fixed by moving away from `Store::retrieve_for_module()`.
2018-03-02 21:25:48 +01:00
78fe9b8cc5 Change "imag" impl to not instantiate Runtime object
Adapt libimagrt interface to export the functions we need to do this.
This is not that nice, but the best approach without rewriting large
parts of libimagrt.
2018-02-26 22:10:23 +01:00
Dylan DPC
e7a5e73d25 Update Cargo.toml 2018-02-26 17:04:53 +05:30
6055520519 Provide unlink() to remove all links 2018-02-25 18:59:02 +01:00
1521005e79
Merge pull request #1307 from matthiasbeyer/libimagstore/entry-parse-fix
Rewrite entry parsing algorithm
2018-02-20 22:03:00 +01:00
9fb5f453fe Rewrite entry parsing algorithm
Rewrite without regex crate.

The regex approach was broken. If the following _content_ was provided
in the entry:

    foo

    ---

    bar

The regex approach parsed the header until the "---" in the content.
This is, of course, not the way to do that.

Now, the parsing is implemented by hand. Should be faster as well,
though I don't care about this.

This fixes a severe bug.
2018-02-20 21:06:36 +01:00
732fc32b75 Fix trace count space width
Was five here, but should be four.
2018-02-20 20:24:27 +01:00
b2048b3dcf
Merge pull request #1306 from matthiasbeyer/minor
Minor patches
2018-02-20 20:23:41 +01:00
00b86709b6 Use writeln!() instead of write!() 2018-02-20 19:24:34 +01:00
461bebe60a
Merge pull request #1302 from matthiasbeyer/libimagdiary/fix-set-isflag
libimagdiary: Add "isflag" support
2018-02-20 18:37:48 +01:00
404e9deed2 Add some debug output 2018-02-20 17:29:03 +01:00
585261d468 Add "isflag" support 2018-02-20 17:18:46 +01:00
5773e8a6c8 Remove libimagentrylist 2018-02-20 15:02:46 +01:00
027c4b3287 Remove usage of libimagentrylist 2018-02-20 15:02:46 +01:00
2c0c8347e9
Merge pull request #1285 from matthiasbeyer/libimagentryref/refactor
libimagentryref: Rewrite
2018-02-19 14:18:17 +01:00
7653a040da
Merge pull request #1294 from matthiasbeyer/libimagstore/store-debug-fix
Simplify Store debug impl
2018-02-19 12:27:37 +01:00
88ffe8084c Merge branch 'libimagentrymarkdown/refactor-libimagref-api-usage' into libimagentryref/refactor 2018-02-19 12:17:53 +01:00
b9b15957fc Merge branch 'libimagmail/rewrite-libimagref-api-usage' into libimagentryref/refactor 2018-02-19 12:17:48 +01:00
672873c2f1 Make UniqueContactPathGenerator pub 2018-02-19 12:15:39 +01:00
719daf952b Refactor libimagcontact for new libimagentryref API 2018-02-19 12:15:39 +01:00
c36250e42f Adapt to new libimagentryref API 2018-02-19 12:15:31 +01:00
30ad7d89b1 Reimplement libimagmail for new libimagentryref interface 2018-02-19 12:15:22 +01:00
1153fb180b Add function to delete a reference header entry 2018-02-19 12:14:32 +01:00
fd6a7f877a Remove private macro 2018-02-19 12:14:32 +01:00
a1a85f40d0 Add default generators 2018-02-19 12:14:32 +01:00
2328c8b2b0 Take AsRef<str> rather than &String 2018-02-19 12:14:32 +01:00
cbb47cffcb Implement Ref functions 2018-02-19 12:14:32 +01:00
ed69fd4b35 Enrich error types 2018-02-19 12:14:32 +01:00
81a8826740 Add impl for RefStore::{get,create,retrieve}_ref() 2018-02-19 12:14:32 +01:00
1014f58cfc Rewrite interface 2018-02-19 12:14:32 +01:00
73af121882 Remove old concepts 2018-02-19 12:14:32 +01:00
5f99018807 Simplify store debug print 2018-02-19 11:51:21 +01:00
c2dfb2ef52 Refactor timetrack subcommands output for broken pipe errors 2018-02-19 11:14:18 +01:00
6a341d3723 Abstract exit code as a type 2018-02-19 11:14:18 +01:00
256bc47222 Refactor into two independent extensions 2018-02-19 10:40:26 +01:00
39107c5296 Add result extension for translating io errors to exit codes 2018-02-19 10:40:26 +01:00
841d3ffb60 Remove OnErr extension which is not used 2018-02-18 20:04:22 +01:00
2b26db70ed Make HabitBuilder derive Debug 2018-02-18 20:03:50 +01:00
3341e3640c
Merge pull request #1224 from matthiasbeyer/git-version-in-version
Git version in version
2018-02-18 20:03:09 +01:00
3bd8822f4f Use version string from git, if present 2018-02-13 11:53:51 +01:00
f5f4fbc397 Add buildscript and infrastructure to include git information in version 2018-02-13 11:38:34 +01:00
5b07baddf8 Add error convenience extension 2018-02-12 21:22:39 +01:00
50b0ffa6ae Remove calls to trace_error_exit() 2018-02-12 21:19:48 +01:00
074f9826fd Implement own displaying implementation for the chain 2018-02-12 21:19:48 +01:00
503b042690 Adapt libimagrt to new error handling 2018-02-12 21:19:47 +01:00
6dd24f3da3 Keep trace_error{,_dbg} for backwards compatibility 2018-02-12 21:19:47 +01:00
e481dbfd12 Rewrite libimagerror to be thin layer over error-chain 2018-02-12 21:19:47 +01:00
4a4e528aed Refactor error handling
Refactor error handling so we do chain the error with the `?`
operator rather than wrapping it with own types.

Links to other error chains are created with error chain. All unneeded
error kinds were removed.

No API changes.
2018-02-11 23:44:27 +01:00
77be32d80f Remove "get" iterator, store provides this now 2018-02-11 23:44:27 +01:00
9e3c966d84
Merge pull request #1273 from matthiasbeyer/update-version-numbers
Update version string: 0.6.0 -> 0.7.0
2018-02-11 17:50:52 +01:00
2e4c29dd07
Merge pull request #1277 from matthiasbeyer/libimagstore/store-debug-output-prettify
Prettify Store debug output implementation
2018-02-11 15:19:13 +01:00
30d2c28a22 Update version string: 0.6.0 -> 0.7.0 2018-02-11 14:22:24 +01:00
8fcd2a6c8c Prettify Store debug output implementation 2018-02-11 13:36:37 +01:00
fa8af0c053
Merge pull request #1275 from matthiasbeyer/clap-features
Clap features
2018-02-11 13:29:17 +01:00
863b52c2f0 Add TraceIterator::trace_unwrap_exit()
* Exits on the first Err(_)
* Introduces new Iterator type for iterating with unwrap and exit on
  error
2018-02-10 16:41:06 +01:00
8656a38c50 Update dependency: clap: 2.17 -> 2.29 2018-02-10 16:40:34 +01:00
9d2900a7dc Compile clap with suggestions and color support 2018-02-10 16:40:34 +01:00
3b710e082d Add missing Cargo.toml metadata 2018-02-10 14:11:46 +01:00
d5a9e4930d Update dates in license header
And add missing header in one file
2018-02-07 02:48:53 +01:00
29e88c5de0 Fix: Header entry setting
The header was not set properly. This fixes this bug.
2018-02-06 20:42:43 +01:00
346e5a9444 Add link to toml_query error types 2018-02-06 20:42:43 +01:00
e2e3b4f6e2 Update kairos dependency: 0.1.0-beta-2 -> 0.1.0 2018-02-05 16:20:05 +01:00
de613c9ebd
Merge pull request #1227 from matthiasbeyer/libimagentryutil/filtered-iterators
libimagentryutil: filtered iterators
2018-02-01 20:22:12 +01:00
3aa2e6edec Add iterator helper for filtering 2018-02-01 16:46:57 +01:00
06cb8d50fb Make StoreId::is_in_collection() generic over AsRef<str> 2018-02-01 16:46:57 +01:00
eb6ab8f029 Add IsInCollection helper type 2018-02-01 16:46:57 +01:00
da0c1fa594 Rewrite From<> implementations for habit iterators
to be generic over all iterators over StoreIds, so they can be build
directly from them.
2018-02-01 16:46:38 +01:00
3c1a0a51c9 Transform iterator to forget Store reference here 2018-02-01 16:46:38 +01:00
b3f546129a Add StoreIdIteratorWithStore::without_store() 2018-02-01 16:46:38 +01:00
8e931cd79f Change calls to into_get_iter() to not take argument 2018-02-01 16:46:38 +01:00
3b01a9eb2f Add API in StoreIdIteratorWithStore to get acting iterators
This patch adds API functions in the StoreIdIteratorWithStore iterator
type to transform it into a iterator which _does_ something (as in the
`libimagstore::iter` API).

It mimics the API which is offered by `libimagstore::iter`.
2018-02-01 15:47:39 +01:00
030e32e44f Provide StoreId Iterator which has a ref to the Store
This change is needed so we can refactor the "get" iterator to not take
an argument (the store) later, which improves the API.
2018-02-01 15:47:39 +01:00
da4b823048
Merge pull request #1219 from matthiasbeyer/minor
Minor patches
2018-02-01 13:18:31 +01:00
92c04c606c Refactor to use AsRef<str> 2018-02-01 09:26:33 +01:00
7e53ad9f78 Add datetime <-> string conversion utility 2018-02-01 09:26:33 +01:00
4d94791b1f Move date <-> string conversion utility to libimagutil 2018-02-01 09:26:33 +01:00
7ecaad830c Refactor to use Iterator::fold() 2018-01-29 09:38:32 +01:00
164b6b7f10 Move documentation to appropriate place 2018-01-29 09:38:32 +01:00
7731b88c97 Remove map_err_trace_exit() calls in favour of map_err_trace_exit_unwrap() 2018-01-29 09:38:32 +01:00