Commit graph

175 commits

Author SHA1 Message Date
01db294700 Add Runtime::input_is_pipe()
We need this because we might want to check whether we can get the STDIN
handle from the runtime or not.
In some (rare) cases, the runtime "thinks" that STDIN is a stream of
IDs, but it is not. So the client can check whether stdin is a pipe
(thus, whether Runtime thinks that there's a stream of IDs) and easily
work around that by taking ::std::io::stdin() itself.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-11-09 15:51:09 +01:00
cc8150e0a9 Add extension trait for iterator over Result<Entry>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-27 13:39:34 +01:00
39cf75a532 Add iterator extensions for store-id touched reporting
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-27 13:39:34 +01:00
Leon Schuermann
7a37c47263 Add ImagApplication trait for CLI completion + single-binary support
To re-add the imag-binary CLI completion, as well as to enable
building a single imag containing all of the subcommands, this commit
introduces an ImagApplication trait to be implemented by all imag
binary crates. The binary crates will be converted to libraries, with
an additional binary target. This enables standalone and single binary
builds.

On its own, this commit doesn't do much, but rather it paves the way
to dynamically interacting with the imag uis/clis using a
library-crate interface.

Signed-off-by: Leon Schuermann <leon@is.currently.online>
2019-10-26 14:41:31 +02:00
2a23002a07 Fix: --override-config argument can be passed multiple times
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-13 12:21:57 +02:00
613b78f369 Update dependency: ansi_term: 0.11.0 -> 0.12 2019-10-07 18:18:28 +02:00
5edb470a5f Update dependency: handlebars: 1.1.0 -> 2 2019-10-07 18:18:28 +02:00
07f949056e Update dependency: env_logger: 0.6.1 -> 0.7
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-07 18:18:28 +02:00
flip1995
7b5f216e01 [No-auto] lib/core/rt: Fix Clippy warnings
Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28 18:18:41 +02:00
flip1995
c7ac440c92 [Auto] lib/core/rt: Fix Clippy warnings
Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28 18:18:40 +02:00
0d1cfb6b4b Refactor: Do not provide functions for these identifiers
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-07-26 23:20:50 +02:00
9c896eb98b Add checks whether variables are valid unicode and propagate appropriate error
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-07-25 19:52:49 +02:00
5f10ab976f Rewrite get_rtp_match() to not panic
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-07-24 21:32:21 +02:00
c09c5b8bad Remove use of Itertools
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-30 19:27:54 +02:00
2185d44011 Update all dependencies
This patch updates all dependencies but not "nom".

Done with `cargo upgrade --all` and manual editing.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-30 16:44:23 +02:00
11c2cab916 Allow unused variable here 2019-06-22 12:00:07 +02:00
2268fd8091 Import toml-query with typed feature
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
5f5ce54edb Rewrite to use derive macro
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 09:39:22 +02:00
a3f771ca65 Add comment why we do this
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 09:32:07 +02:00
fb8b50fa9a Remove boilerplate by enabling serde in "log" dependency
This patch adds the "serde" feature to the "log" dependency, so we can
deserialize logging levels directly into "log" types.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 09:32:07 +02:00
185ec25b9e Rewrite logging config deserialization
This patch rewrites the logging config deserialization. It removes the
manual traversing of the config toml structure and replaces it with
types which implement `Deserialize`, which is way more convenient and
easy to read (and extend).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 09:32:07 +02:00
a7d53e47d1 Update toml-query to 0.9.0
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29 18:39:25 +02:00
1482f70320 Update dependency: toml: 0.4 -> 0.5
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29 18:39:25 +02:00
Leon Schuermann
ed457495c8 Introduce proper error handling in IdPathProvider
Prior to this change, the IdPathProvider implementation would be
responsible for exiting the process on insufficient / wrong arguments.
However, such error handling should be performed together with the
business logic and not in CLI-parsing related code.

This change introduces a clear separation: both parsing errors and
insufficient id path arguments can now be return from inside the
`get_ids`-method, and get passed up to the application logic to be
handled.

This change is reflected in all instances of IdPathProvider and their
surrounding code.

Signed-off-by: Leon Schuermann <leon.git@is.currently.online>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-24 21:03:34 +02:00
00fa3e7b78 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:53:40 +02:00
1d89844613 Run 'cargo fix' for rust-2018
With this patch we move the codebase to Rust-2018.

The diff was generated by executing

    cargo fix --all --all-features --edition

on the codebase.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:20:59 +02:00
de522ec0f2 Fix for rust beta compiler
The beta compiler reports duplicated input:

error: the item `IntoValues` is imported redundantly
   --> lib/entry/libimagentrylink/src/internal.rs:398:13
    |
36  | use self::iter::IntoValues;
    |     ---------------------- the item `IntoValues` is already imported here
...
398 |         use internal::iter::IntoValues;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |

so we fix this here.

Other imports were fixed as well.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13 22:06:53 +02:00
82a2fa1528 Remove old TODO
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
22c239c212 Add output about logger settings in logging setup
This way we can get trace-level information about the logger itself when
it is generated. Because from time to time we might want to have a look
at that.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-19 21:51:44 +01:00
a6ad19a14f Merge branch 'redefine-storeid'
Finally merging the redefine of the StoreId implementation, which allows
easier handling of StoreId objects.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:58 +01:00
9af7e9a9ab Remove unused variable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:06 +01:00
642702b724 Rewrite: StoreId::new_baseless() -> StoreId::new()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
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
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
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
751ce5af1a Simplify implementation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
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
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
d936b611fc Fix config override mechanism
The bug was that we did not actually _set_ the new value.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 00:47:41 +01:00
e4ef6f0649 Remove log-destination-override features
This removes the feature to be able to override log destinations from
the commandline.

This feature is removed because the --override-config feature from the
runtime already contains this functionality. It is a little more complex
to use, though this is a feature hardly used at all, so I rather go for
less code (less complexity) here than feature bloat.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-05 01:03:39 +01:00
3fbfb19419 Add runtime feature: Ignore id reporting
This feature gives the users of the Runtime API the possibility to check
whether the user wants the ID reporting to be ignored as well (and more
important) to override the default behaviour where the runtime assumes
that if STDOUT is a pipe, it is a pipe to an imag command.

Before, this would not have been possible:

    imag contact find Jonas --json | jq 'map(.fullname)'

because the runtime automatically prints the output of the command to
stderr and the touched IDs to stdout.
But now with this change, a user can override this default behaviour and
do:

    imag contact --ignore-ids find Jonas --json | jq 'map(.fullname)'

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-05 00:55:30 +01:00
9185abcfa5 Update copyright years
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-01-03 18:41:36 +01:00
9fca66aa89 Forbid unsafe code in all crates 2018-11-11 13:05:55 +01:00
4e516ee19d Update version strings
...for the next release, which will be imag 0.10.0!

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-10 11:56:37 +01:00
17d4123898 Update dependencies from git versions to proper versions.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-09 22:14:11 +01:00
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
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
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
feea57679d Remove scope
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:04:47 +01:00
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