Commit Graph

5890 Commits

Author SHA1 Message Date
Matthias Beyer 207fd88c3d Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer d2c031920a Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer ebf3f309a6 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 187b948985 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 83415e78b9 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer f64b87b4a8 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer c6cc1804e7 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer b4f401675e Add Entries::into_storeid_iter()
This is a more complicated functionality (implementation-wise) of the
`Entries` iterator, which allows a callee to transform it into a
`StoreIdIterator`.

It uses the crate internal `PathIterator` type and a function to extract
the internals of that iterator which is then turned into an iterator
over `Result<StoreId>`, which can be used to build a `StoreIdIterator`.

The implementation is ugly, but we need to be able to transform a
`Entries` iterator into a `StoreIdIterator` in the
`libimagentryannotation`, and possibly in more cases where we want to be
agnostic over iterators.

Maybe there is a cleaner solution to this, hence the comment about
whether this should be removed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 2e7c17d5dc Fix libimagcontact for new StoreId interface with Entries iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer b383e082fb Fix libimagtodo for new StoreId interface with Entries iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 14a2485a8a Change signature: Link::exists(&Store)
This change is necessary because we need the store now to check whether
a StoreId exists.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 429ef9bc4c Fix libimagentrylink for new StoreId API
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 642702b724 Rewrite: StoreId::new_baseless() -> StoreId::new()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer b66371f79b Rewrite Store::new* API: libimagstore does not export backend types
With this change applied, libimagstore does not export backend
representing types anymore.

This change is necessar because when we want to switch the `StoreId`
implementation from "complex and stateful" to "Stateless and Cow<'_,
&str>", we need to be able to have a type which represents a "`StoreId`
plus the path of the Store itself".
This "the path of the Store itself" is passed around as reference, to
minimize runtime impact.

Because such a type should not be exported by the libimagstore crate, we
make it `pub(crate)` internally. But because the backend APIs also have
to use this type, we would export the (private) type in the APIs of the
backend.

Because of that we make the backend API also non-visible to crate users,
which also decreases the surface of the libimagstore API itself.

Besides:
Remove function `Link::with_base()` which is not needed anymore (was
used in tests only).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 35a500f91c Delete unused code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 04a8c5f721 Move to simpler implementation of Storeid
This changes the implementation of the StoreId type to be less complex.
Before we always had to re-attach the path of the store itself each time
a StoreId object was passed to the store. Now we do not do this anymore,
hopefully we can move to a implementation of the Store API which takes
references of StoreId objects in the future.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer dc162cb167 Fix: Off by one error
When printing the error chain, we print the error and then iterate over
the causes. Hence, we have to increase the printed number by one here,
because 0 (zero) is already printed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:56:13 +01:00
Matthias Beyer 2611583839 Fix: Also print if runtime ignores IDs
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:13:29 +01:00
Matthias Beyer 45cb122f53 Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:05:09 +01:00
Matthias Beyer 0916c92a18 Bugfix: Rebuild iterator when changing collection
This patch fixes a bug where the following code (here pseudocode) did
the wrong thing:

    store.entries().in_collection("foo").for_each(||...)

because the `.in_collection()` call for the underlying PathIterator
object did not actually re-build the iterator. It only changed the
contained `PathIterBuilder`, but did not call `.build_iter()` on it to
rebuild the iterator object.

The test added with this patch checks whether the iterator does the
right thing.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 18:29:15 +01:00
Matthias Beyer 2a07c8a0c2 Do not use deprecated way of checking whether path exists
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-12 19:04:15 +01:00
Matthias Beyer 86dca4887d Fix negation error
We Iterator::filter here, so we have to negate - because we list
everything where _no_ instance exists yet.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 334e9e3954 Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer c98ec920a3 Adapt for new interface of gen_vars() function
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 7680dcf3b8 Make generate_variants() more flexible
This patch changes generate_variants() so that it allows to be passed an
iterator for the modders, which makes it more powerful for passing
references.
2019-02-11 03:52:04 +01:00
Matthias Beyer b985c510aa Optimize: Do not iterate over entries outside of "timetrack" collection
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer fe9409a5dc Do not print table if table is empty anyways
When listing timetrackings, we do not want to print an empty table if
there aren't any timetrackings.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 81912ac5cd Add wrapping functionality for imag-log
This patch adds a wrapping functionality to imag-log.
The commandline parameter `-w` or `--wrap` can not be used to wrap the
output at N characters, defaulting to 80 characters.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 171b42307d Add feature to trim content on the right
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 0ba19daa57 Strip whitespace on the right when printing
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 90eaeb642a Remove magic constants in trace_unwrap_exit/map_err_trace_exit_unwrap calls
This patch removes the magic constant we used when calling
`trace_unwrap_exit()` or `map_err_trace_exit_unwrap()`.
We used to call it with `1` as parameter, where the number was the exit
code to use. Now the implementation of the function does it
automatically (using 1 (one) as exit code).

All calls of these functions were fixed. Thanks to vim this was easy.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 01fa19aade Remove clone() calls
We should be able, from the signature of the `generate_variants()`
helper function, to pass a `Vec<&T>` here, so cloning should not be
necessary.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:23:17 +01:00
Matthias Beyer 6b34e99b75 Make doc comment test executable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:23:17 +01:00
Matthias Beyer 751ce5af1a Simplify implementation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer 8a4bc0eba4 Simplify implementation of Wiki::all_ids()
This way we alter the underlying iterator for all wiki entries to only
iterate in the "wiki" collection of the store, which results in fewer
disk access because the internal iterator does not yield all pathes from
the store before filtering them.

Code which was used to implement the filter was removed (also from the
public interface of the library).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer c29e05bc25 Simplify implementation of ContactStore::all_contacts()
This way we alter the underlying iterator for all contacts to only
iterate in the "contact" collection of the store, which results in fewer
disk access because the internal iterator does not yield all pathes from
the store before filtering them.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer eed577db15 Add trace!() call to show config when runtime initializes
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer c8e74193b3 Optimize: Do not attempt to print if output is a pipe
This is a small optimization so that we do not print the information if
the output is a pipe anyways.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer f1a639ea8c Change id reporting API to return ExitCode
Because this API only errors when write!() errors occur, we can return
the exit code as an error here.

This way the user of the API can immediately exit if there was an IO
error, but the API automatically takes care of the right return value,
returning (exiting) with zero (0) if there was an "Broken pipe" error
and with one (1) otherwise, which is the expected behaviour here.

All calls to that API were changed accordingly.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer 19912f5e88 Add Is::remove_isflag() for removing header flags
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer 96a25c18b2 doc: Rewrite imag-mail documentation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 17:14:48 +01:00
Matthias Beyer 73d8d54528 doc: Add notes on CLI conventions
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 17:14:45 +01:00
Matthias Beyer 5775a3461a doc: Add note that sorting in collections is no hard rule
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 17:14:42 +01:00
Matthias Beyer de8e065eec doc: Rewrite docs for todo module parts
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 17:14:21 +01:00
Matthias Beyer 03e0864268 Merge branch 'unnamed-annotations' into master-ff
This merge adds several patches to improve libimagannotation and
imag-annotate.
2019-02-10 17:07:35 +01:00
Matthias Beyer 53022443ab Rewrite iteration
This patch rewrites how imag-annotate iterates over the ids to process
to be more easily to understand.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 01:00:38 +01:00
Matthias Beyer d8cd10a384 Remove iterator types
With this patch, libimagentryannotation does not have special iterator
types anymore. This makes the whole thing more comfortable to use.

In imag-annotate, the parameter for the functioncall was removed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 01:00:33 +01:00
Matthias Beyer c84258da3d Add flag to not print name of annotation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 00:58:21 +01:00
Matthias Beyer ab5078f111 Rewrite "add annotation" command
Because before we created a new annotation for each ID to be annotated,
which is not the expected behaviour.

Now we create one annotation object and then link it to all IDs which
are provided on the commandline.

Also, the annotation name is printed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 00:58:21 +01:00
Matthias Beyer ed01f8b463 Make annotations unnamed (automatically UUID named)
It makes no sense to name annotations, a user only cares about whether
there are annotations or not, or their contents. A name has no meaning
in this context.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 00:58:21 +01:00