From 3090a65446bcd3153806403a9ed1e73e87f37e57 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 10 Oct 2018 23:17:19 +0200 Subject: [PATCH 01/11] Add detailed comments on how the logger works --- lib/core/libimagrt/src/logger.rs | 35 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/core/libimagrt/src/logger.rs b/lib/core/libimagrt/src/logger.rs index f7d09697..d8b6c781 100644 --- a/lib/core/libimagrt/src/logger.rs +++ b/lib/core/libimagrt/src/logger.rs @@ -174,28 +174,35 @@ impl Log for ImagLogger { self.module_settings .get(record_target) .map(|module_setting| { + // We have a module setting some + // * Check whether logging is enabled for this module and + // * check whether the module logging level is >= or, if there is no module logging + // level, + // * check whether the global logging level is >= the record level. let set = module_setting.enabled && module_setting.level.unwrap_or(self.global_loglevel) >= record.level(); - if set { + if set { // if we want to log from a setting standpoint + // get the destinations for the module and log to all of them module_setting.destinations.as_ref().map(|destinations| for d in destinations { - // If there's an error, we cannot do anything, can we? - let _ = log_to_destination(&d); + let _ = log_to_destination(&d); // ignore errors, because what else? }); + // after that, log to the global destinations as well for d in self.global_destinations.iter() { - // If there's an error, we cannot do anything, can we? - let _ = log_to_destination(&d); + let _ = log_to_destination(&d); // ignore errors, because what else? } } }) + + // if we do not have a setting for the record target .unwrap_or_else(|| { - if self.global_loglevel >= record.level() { - // Yes, we log - for d in self.global_destinations.iter() { - // If there's an error, we cannot do anything, can we? - let _ = log_to_destination(&d); - } + if self.global_loglevel >= record.level() { // if logging is enabled for that level + self.global_destinations + .iter() + .for_each(|d| { // log to all global destinations + let _ = log_to_destination(&d); // ignore errors, because what else? + }); } }); } @@ -287,14 +294,14 @@ fn translate_destinations(raw: &Vec) -> Result> { fn aggregate_global_destinations(matches: &ArgMatches, config: Option<&Value>) -> Result> { - + let config_log_dest_path = "imag.logging.destinations"; match config { Some(cfg) => cfg - .read("imag.logging.destinations")? + .read(&config_log_dest_path)? .ok_or_else(|| RE::from_kind(EK::GlobalDestinationConfigMissing))? .as_array() .ok_or_else(|| { - let path = "imag.logging.destinations".to_owned(); + let path = config_log_dest_path.to_owned(); let ty = "Array"; RE::from_kind(EK::ConfigTypeError(path, ty)) }) From 4beeef080b4e07eaa1ee3bd3b9f918e425996142 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 12 Oct 2018 14:57:01 +0200 Subject: [PATCH 02/11] travis: Add CI job for beta rust version --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3d4aa4b0..5b0a0af3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,6 +45,16 @@ matrix: script: - cargo build --all --all-features -j 1 || exit 1 - cargo test --all --all-features -j 1 || exit 1 + - language: rust + rust: beta + cache: + directories: + - /home/travis/.cargo + before_cache: + - rm -rf /home/travis/.cargo/registry + script: + - cargo build --all --all-features -j 1 || exit 1 + - cargo test --all --all-features -j 1 || exit 1 addons: From 05d43128ceef3db89095d2ee2b83acf357ea2fde Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 12 Oct 2018 17:44:57 +0200 Subject: [PATCH 03/11] Update script Basically a complete rewrite. This now is able to parse git installed imag version strings and behave accordingly. Signed-off-by: Matthias Beyer --- scripts/which-commands-changed | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/which-commands-changed b/scripts/which-commands-changed index 62a48593..4a179633 100755 --- a/scripts/which-commands-changed +++ b/scripts/which-commands-changed @@ -2,11 +2,22 @@ # Find all imag commands which changed since last install -imag versions |\ -grep "imag-" |\ -sed 's,v.*-g,,' |\ +imag versions 2>&1 | \ +grep "imag-" | \ +sed 's,\ *->.*\ , ,' | \ while read binary hash; do - git diff "$hash..master" --name-only | \ - grep "$binary" >/dev/null 2>/dev/null && \ - echo "$binary changed since last install (was $hash)" + if [[ "$hash" =~ v.*\..*\..*- ]]; then + hash="$(echo "$hash" | sed 's,.*-g,,')" + fi + + log="$(git diff --name-only ${hash}..master 2>/dev/null)" + if [[ $? -eq 0 ]]; then + echo "$log" | \ + grep "$binary" >/dev/null 2>/dev/null && \ + echo -e "changed since last install ($hash): $binary" + else + echo "WARN: Could not check $binary because git hash '$hash' is not present" + fi + done + From d87ea7b305d71dd9633e5862f2d481007e1361b3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 13 Oct 2018 11:51:15 +0200 Subject: [PATCH 04/11] Add StoreId::local_display_string() function for safely creating a `String` object from `StoreId` which can be shown to the user. Mainly introduced because this is useful for error handling (when putting a `StoreId` into an error kind, the compiler complains that `StoreId` does not meet the required trait bounds. But `String` does and we do not process the ID any further anyways). Signed-off-by: Matthias Beyer --- lib/core/libimagstore/src/storeid.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/core/libimagstore/src/storeid.rs b/lib/core/libimagstore/src/storeid.rs index 2f2bf723..0908a3b7 100644 --- a/lib/core/libimagstore/src/storeid.rs +++ b/lib/core/libimagstore/src/storeid.rs @@ -128,6 +128,18 @@ impl StoreId { .ok_or_else(|| SE::from_kind(SEK::StoreIdHandlingError)) } + /// Helper function for creating a displayable String from StoreId + /// + /// This is safe because the + /// + /// impl ToString for T + /// + /// does only fail if Display::display() failed. The implementation of ::std::path::Display and + /// the implementation ::std::fmt::Display for ::std::path::Display do not return errors though. + pub fn local_display_string(&self) -> String { + self.local().display().to_string() + } + /// Returns the components of the `id` part of the StoreId object. /// /// Can be used to check whether a StoreId points to an entry in a specific collection of From 325c5ddbd05f0bb467f4ccf942deb49d1af6eef1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:48 +0200 Subject: [PATCH 05/11] Fix: URL in imag helptext Signed-off-by: Matthias Beyer --- bin/core/imag/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/core/imag/src/main.rs b/bin/core/imag/src/main.rs index fbaa974e..9b8267ca 100644 --- a/bin/core/imag/src/main.rs +++ b/bin/core/imag/src/main.rs @@ -91,7 +91,7 @@ fn help_text(cmds: Vec) -> String { Call a command with 'imag ' Each command can be called with "--help" to get the respective helptext. - Please visit https://github.com/matthiasbeyer/imag to view the source code, + Please visit https://git.imag-pim.org/imag to view the source code, follow the development of imag or maybe even contribute to imag. imag is free software. It is released under the terms of LGPLv2.1 From 9e0194ac6b2a9ce56938f9485f9894f194b5f08e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:49 +0200 Subject: [PATCH 06/11] Remove status badge They do not render on our git hosting and as we're moved away from github, we don't need them anymore. Signed-off-by: Matthias Beyer --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index a645196d..b1abb6ad 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,6 @@ `imag` is a commandline personal information management suite. -[![Build Status](https://travis-ci.org/matthiasbeyer/imag.svg?branch=master)](https://travis-ci.org/matthiasbeyer/imag) -[![Issue Stats](http://www.issuestats.com/github/matthiasbeyer/imag/badge/pr?style=flat-square)](http://www.issuestats.com/github/matthiasbeyer/imag) -[![Issue Stats](http://www.issuestats.com/github/matthiasbeyer/imag/badge/issue?style=flat-square)](http://www.issuestats.com/github/matthiasbeyer/imag) -[![license](https://img.shields.io/github/license/matthiasbeyer/imag.svg?maxAge=2592000?style=flat-square)]() -[![Tokei](https://tokei.rs/b1/github/matthiasbeyer/imag)](https://github.com/matthiasbeyer/imag) - **This application is in early development. There are _some_ things that work, but we do not consider anything stable or usable at this moment. Feel free to play around anyways.** From 33210dbde0fa6f770245980659262db6c83bcee1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:50 +0200 Subject: [PATCH 07/11] Update README Things done: * Remove all hints on "issues and pull requests", as these are github-terms. Use "issues" in context of "mailinglist" instead. * Remove some unessesary details on how to build only parts of imag * Minor updates on the usage examples * Other minor tweaks. Signed-off-by: Matthias Beyer --- README.md | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index b1abb6ad..05efdba3 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ early 2019. I hope I can continue develop imag during that time, but I cannot guarantee that. I hope I can continue development of imag after that and I certainly plan to do so. -But from May 2018 until early 2019, expect long response times on issues and -pull requests. +But from May 2018 until early 2019, expect long response times. ## Goal / What is imag? @@ -44,24 +43,14 @@ All subdirectories prefixed with "`libimag"` are libraries. All subdirectories prefixed with `"imag-"` are binaries and compiling them will give you a commandline application. + ### Building We use `cargo` for building all crates in this repository. Make sure to use a recent `cargo`, at least one with workspace support. Building all crates works with `cargo build --all`, building individual crates -by `cd`ing to their directory and calling `cargo build`. +by specifying the `--manifest-path` flag to cargo. -For building all commandline applications: - -```bash -find bin -maxdepth 3 -name Cargo.toml -exec cargo build --manifest-path {} \; -``` - -For building only the core functionality - -```bash -find bin/core -maxdepth 3 -name Cargo.toml -exec cargo build --manifest-path {} \; -``` ### Running @@ -69,8 +58,10 @@ After you build the module you want to play with, you can simply call the binary itself with the `--help` flag, to get some help what the module is capable of. If you installed the module, you can either call `imag-` (if the -install-directory is in your `$PATH`), or install the `imag` binary to call `imag -` (also if everything is in your `$PATH`). +install-directory is in your `$PATH`), or install the `imag` binary to call +`imag ` (also if everything is in your `$PATH`). +Call `imag --help` to see which modules are found and can be used. +Call `imag --versions` to print the versions of all modules. ## Example usage @@ -91,7 +82,7 @@ imag contact create --file /home/user/contacts/private # Add a diary entry imag diary -p private create -# Uh, I forgot something in a diary entry, select one and edit it +# Uh, I forgot something in a diary entry, select one (or multiple) and edit it # use the `fzf` tool here (not a part of imag) to select from the IDs imag diary -p private list | fzf -m | imag edit -I @@ -105,7 +96,7 @@ imag annotate add contact/bc222298-casf-40a4-bda1-50aa980a68c9 contact-notes imag notes create "pineapple" # Where was that contact again? -imag grep Eva +imag grep Eva # also possible with `imag contact find Eva` # Okay, we need to add some imag-internal notes to that contact imag grep Eva -l | imag edit -I @@ -118,7 +109,7 @@ imag git commit -m 'Commit message' ## Staying up-to-date We have a [official website for imag](https://imag-pim.org), where I post -[release notes](http://imag-pim.org/releases/) and monthly(ish) updates what's +[release notes](https://imag-pim.org/releases/) and monthly(ish) updates what's happening in the source tree ([RSS here](https://imag-pim.org/index.xml)). We also have a [mailinglist](https://imag-pim.org/mailinglist/) where I post @@ -128,7 +119,7 @@ updates and where discussion and questions are encouraged. ## Documentation We have some documentation in [the ./doc subtree](./doc/) -which can be compiled to PDF or a website. +which can be compiled to PDF or a website using pandoc. It might not be up to date, though. Developer documentation for the last release is available [on docs.rs](https://docs.rs/releases/search?query=imag). @@ -137,8 +128,9 @@ Developer documentation for the last release is available ## Please contribute! We are looking for contributors! -Feel free to open issues for asking questions, suggesting features or other -things! +Feel free to open issues (by writing to +[the mailinglist](https://imag-pim.org/mailinglist/)) +for asking questions, suggesting features or other things! Also have a look at [the CONTRIBUTING.md file](./CONTRIBUTING.md)! From 0d103653ea3f740eed874a457d9bdbaf3036dee5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:51 +0200 Subject: [PATCH 08/11] Update about-text in imag-ids Signed-off-by: Matthias Beyer --- bin/core/imag-ids/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/core/imag-ids/src/main.rs b/bin/core/imag-ids/src/main.rs index 308a56aa..f69fd891 100644 --- a/bin/core/imag-ids/src/main.rs +++ b/bin/core/imag-ids/src/main.rs @@ -68,7 +68,7 @@ fn main() { let version = make_imag_version!(); let rt = generate_runtime_setup("imag-ids", &version, - "print all ids", + "Print all ids, optionally filtered with a user-defined filter", build_ui); let print_storepath = rt.cli().is_present("print-storepath"); From 5b4715b3117c402fcfb894842e5e91de4734432b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:52 +0200 Subject: [PATCH 09/11] Update about-text in imag-link Signed-off-by: Matthias Beyer --- bin/core/imag-link/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/core/imag-link/src/main.rs b/bin/core/imag-link/src/main.rs index cb40de5c..5a177308 100644 --- a/bin/core/imag-link/src/main.rs +++ b/bin/core/imag-link/src/main.rs @@ -80,7 +80,7 @@ fn main() { let version = make_imag_version!(); let rt = generate_runtime_setup("imag-link", &version, - "Link entries", + "Add/Remove links between entries", build_ui); if rt.cli().is_present("check-consistency") { let exit_code = match rt.store().check_link_consistency() { From f970fc987f82dd11ab74536459e403ee155fd247 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:53 +0200 Subject: [PATCH 10/11] Update about-text in imag-tag Signed-off-by: Matthias Beyer --- bin/core/imag-tag/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/core/imag-tag/src/main.rs b/bin/core/imag-tag/src/main.rs index f07b8b25..01387336 100644 --- a/bin/core/imag-tag/src/main.rs +++ b/bin/core/imag-tag/src/main.rs @@ -80,7 +80,7 @@ fn main() { let version = make_imag_version!(); let rt = generate_runtime_setup("imag-tag", &version, - "Direct interface to the store. Use with great care!", + "Add and remove tags for entries", build_ui); let ids : Vec = rt From 52c5300ec888f367ab829b6e861a552bb842b38e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 17 Oct 2018 11:35:54 +0200 Subject: [PATCH 11/11] Update about-text in imag-wiki Signed-off-by: Matthias Beyer --- bin/domain/imag-wiki/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/domain/imag-wiki/src/main.rs b/bin/domain/imag-wiki/src/main.rs index 6e586009..5d5969b3 100644 --- a/bin/domain/imag-wiki/src/main.rs +++ b/bin/domain/imag-wiki/src/main.rs @@ -48,7 +48,7 @@ fn main() { let version = make_imag_version!(); let rt = generate_runtime_setup("imag-wiki", &version, - "Personal wiki", + "Manage a personal Wiki", build_ui); let wiki_name = rt.cli().value_of("wikiname").unwrap_or("default");