From 5ff2c3e8e38cbcb9480eea4a12d235293b80008c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 19 May 2019 09:14:09 +0200 Subject: [PATCH 1/6] Remove lazy_static we don't need lazy static here, so remove it and the dependency as well. Signed-off-by: Matthias Beyer --- lib/entry/libimagentrydatetime/Cargo.toml | 1 - lib/entry/libimagentrydatetime/src/datetime.rs | 12 +++++------- lib/entry/libimagentrydatetime/src/lib.rs | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/entry/libimagentrydatetime/Cargo.toml b/lib/entry/libimagentrydatetime/Cargo.toml index 726882c4..b3185036 100644 --- a/lib/entry/libimagentrydatetime/Cargo.toml +++ b/lib/entry/libimagentrydatetime/Cargo.toml @@ -22,7 +22,6 @@ maintenance = { status = "actively-developed" } [dependencies] chrono = "0.4" toml-query = "0.8" -lazy_static = "1.2" toml = "0.4" failure = "0.1" diff --git a/lib/entry/libimagentrydatetime/src/datetime.rs b/lib/entry/libimagentrydatetime/src/datetime.rs index d7fcb828..17bbdaa0 100644 --- a/lib/entry/libimagentrydatetime/src/datetime.rs +++ b/lib/entry/libimagentrydatetime/src/datetime.rs @@ -44,12 +44,10 @@ pub trait EntryDate { } -lazy_static! { - static ref DATE_HEADER_LOCATION : &'static str = "datetime.value"; - static ref DATE_RANGE_START_HEADER_LOCATION : &'static str = "datetime.range.start"; - static ref DATE_RANGE_END_HEADER_LOCATION : &'static str = "datetime.range.end"; - static ref DATE_FMT : &'static str = "%Y-%m-%dT%H:%M:%S"; -} +const DATE_HEADER_LOCATION : &'static str = "datetime.value"; +const DATE_RANGE_START_HEADER_LOCATION : &'static str = "datetime.range.start"; +const DATE_RANGE_END_HEADER_LOCATION : &'static str = "datetime.range.end"; +const DATE_FMT : &'static str = "%Y-%m-%dT%H:%M:%S"; impl EntryDate for Entry { @@ -93,7 +91,7 @@ impl EntryDate for Entry { self.get_header_mut() .insert(&DATE_HEADER_LOCATION, Value::String(date)) .context(format_err!("Failed to insert header '{}' in '{}'", - *DATE_HEADER_LOCATION, + DATE_HEADER_LOCATION, self.get_location())) .map_err(Error::from) .map(|opt| opt.map(|stri| { diff --git a/lib/entry/libimagentrydatetime/src/lib.rs b/lib/entry/libimagentrydatetime/src/lib.rs index 3e16e031..2c7e17e1 100644 --- a/lib/entry/libimagentrydatetime/src/lib.rs +++ b/lib/entry/libimagentrydatetime/src/lib.rs @@ -37,7 +37,6 @@ while_true, )] -#[macro_use] extern crate lazy_static; #[macro_use] extern crate failure; extern crate chrono; extern crate toml_query; From 8bac396f09a723e0679f5da00ab580ec37fcca1c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 19 May 2019 10:02:01 +0200 Subject: [PATCH 2/6] Add imag-markdown to release script Fixes: 632062caed ("Add imag-markdown") Signed-off-by: Matthias Beyer --- scripts/release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/release.sh b/scripts/release.sh index ec4da882..09fc299b 100644 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -47,6 +47,7 @@ CRATES=( ./bin/domain/imag-todo ./bin/domain/imag-log ./bin/domain/imag-wiki + ./bin/core/imag-markdown ./bin/core/imag-ref ./bin/core/imag-gps ./bin/core/imag-diagnostics From b18c3e0361f58fca371eed141e7533ac4c078466 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 19 May 2019 12:30:57 +0200 Subject: [PATCH 3/6] Remove ununsed sourcefile Signed-off-by: Matthias Beyer --- lib/etc/libimaginteraction/src/readline.rs | 123 --------------------- 1 file changed, 123 deletions(-) delete mode 100644 lib/etc/libimaginteraction/src/readline.rs diff --git a/lib/etc/libimaginteraction/src/readline.rs b/lib/etc/libimaginteraction/src/readline.rs deleted file mode 100644 index 227bb61d..00000000 --- a/lib/etc/libimaginteraction/src/readline.rs +++ /dev/null @@ -1,123 +0,0 @@ -// -// imag - the personal information management suite for the commandline -// Copyright (C) 2015-2019 Matthias Beyer and contributors -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; version -// 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -// - - -use failure::ResultExt; -use toml::Value; - -use rustyline::{Config, Editor}; - -pub struct Readline { - editor: Editor, - history_file: PathBuf, - prompt: String, -} - -impl Readline { - - pub fn new(rt: &Runtime) -> Result { - let c = rt.config().ok_or(IEK::NoConfigError)?; - - let histfile = c.lookup("ui.cli.readline_history_file").ok_or(IEK::ConfigError)?; - let histsize = c.lookup("ui.cli.readline_history_size").ok_or(IEK::ConfigError)?; - let histigndups = c.lookup("ui.cli.readline_history_ignore_dups").ok_or(IEK::ConfigError)?; - let histignspace = c.lookup("ui.cli.readline_history_ignore_space").ok_or(IEK::ConfigError)?; - let prompt = c.lookup("ui.cli.readline_prompt").ok_or(IEK::ConfigError)?; - - let histfile = histfile - .as_str() - .map(PathBuf::from) - .ok_or(IE::from_kind(IEK::ConfigTypeError)) - .context(IEK::ConfigError) - .context(IEK::ReadlineError)?; - - let histsize = histsize - .as_int() - .ok_or(IE::from_kind(IEK::ConfigTypeError)) - .context(IEK::ConfigError) - .context(IEK::ReadlineError)?; - - let histigndups = histigndups - .as_bool() - .ok_or(IE::from_kind(IEK::ConfigTypeError)) - .context(IEK::ConfigError) - .context(IEK::ReadlineError)?; - - let histignspace = histignspace - .as_bool() - .ok_or(IE::from_kind(IEK::ConfigTypeError)) - .context(IEK::ConfigError) - .context(IEK::ReadlineError)?; - - let prompt = prompt - .as_str() - .ok_or(IE::from_kind(IEK::ConfigTypeError)) - .context(IEK::ConfigError) - .context(IEK::ReadlineError)?; - - let config = Config::builder(). - .max_history_size(histsize) - .history_ignore_dups(histigndups) - .history_ignore_space(histignspace) - .build(); - - let mut editor = Editor::new(config); - - if !histfile.exists() { - let _ = File::create(histfile.clone()) - .context(IEK::ReadlineHistoryFileCreationError)?; - } - - let _ = editor.load_history(&histfile).context(ReadlineError)?; - - Ok(Readline { - editor: editor, - history_file: histfile, - prompt: prompt, - }) - } - - pub fn read_line(&mut self) -> Result> { - use rustyline::ReadlineError; - use libimagutil::warn_result::*; - - match self.editor.readline(&self.prompt) { - Ok(line) => { - self.editor.add_history_line(&line); - self.editor - .save_history(&self.history_file) - .map_warn_err_str(|e| format!("Could not save history file {} -> {:?}", - self.history_file.display(), e)); - return line; - }, - Err(ReadlineError::Interrupted) => { - info!("CTRL-C"); - Ok(None) - }, - Err(ReadlineError::Eof) => { - info!("CTRL-D"); - Ok(None) - }, - Err(err) => Err(err).map_err_into(ReadlineError), - - } - } - -} - From 1c6b02454c5617c6c0b99a9008b76917db3fc699 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 19 May 2019 12:34:51 +0200 Subject: [PATCH 4/6] Remove unused functions --- lib/etc/libimaginteraction/src/ask.rs | 169 -------------------------- 1 file changed, 169 deletions(-) diff --git a/lib/etc/libimaginteraction/src/ask.rs b/lib/etc/libimaginteraction/src/ask.rs index ea112d7c..f36fa2e0 100644 --- a/lib/etc/libimaginteraction/src/ask.rs +++ b/lib/etc/libimaginteraction/src/ask.rs @@ -21,17 +21,14 @@ use std::io::BufRead; use std::io::BufReader; -use std::result::Result as RResult; use std::io::Read; use std::io::Write; use regex::Regex; use ansi_term::Colour::*; -use interactor::*; use failure::Error; use failure::ResultExt; use failure::Fallible as Result; -use failure::err_msg; /// Ask the user for a Yes/No answer. Optionally provide a default value. If none is provided, this /// keeps loop{}ing @@ -67,111 +64,6 @@ fn ask_bool_(s: &str, default: Option, input: &mut R, output: } } -/// Ask the user for an unsigned number. Optionally provide a default value. If none is provided, -/// this keeps loop{}ing -pub fn ask_uint(s: &str, default: Option, input: &mut Read, output: &mut Write) -> Result { - ask_uint_(s, default, &mut BufReader::new(input), output) -} - -fn ask_uint_(s: &str, default: Option, input: &mut R, output: &mut Write) -> Result { - use std::str::FromStr; - - loop { - ask_question(s, false, output)?; - - let mut s = String::new(); - let _ = input.read_line(&mut s); - - let u : RResult = FromStr::from_str(&s[..]); - match u { - Ok(u) => { return Ok(u); }, - Err(_) => { - if default.is_some() { - return Ok(default.unwrap()); - } // else keep looping - } - } - } -} - -/// Ask the user for a String. -/// -/// If `permit_empty` is set to false, the default value will be returned if the user inserts an -/// empty string. -/// -/// If the `permit_empty` value is true, the `default` value is never returned. -/// -/// If the `permit_multiline` is set to true, the `prompt` will be displayed before each input line. -/// -/// If the `eof` parameter is `None`, the input ends as soon as there is an empty line input from -/// the user. If the parameter is `Some(text)`, the input ends if the input line is equal to `text`. -pub fn ask_string(s: &str, - default: Option, - permit_empty: bool, - permit_multiline: bool, - eof: Option<&str>, - prompt: &str, - input: &mut Read, - output: &mut Write) - -> Result -{ - ask_string_(s, - default, - permit_empty, - permit_multiline, - eof, - prompt, - &mut BufReader::new(input), - output) -} - -fn ask_string_(s: &str, - default: Option, - permit_empty: bool, - permit_multiline: bool, - eof: Option<&str>, - prompt: &str, - input: &mut R, - output: &mut Write) - -> Result -{ - let mut v = vec![]; - loop { - ask_question(s, true, output)?; - write!(output, "{}", prompt)?; - - let mut s = String::new(); - let _ = input.read_line(&mut s); - - if permit_multiline { - if permit_multiline && eof.map_or(false, |e| e == s) { - return Ok(v.join("\n")); - } - - if permit_empty || !v.is_empty() { - v.push(s); - } - write!(output, "{}", prompt)?; - } else if s.is_empty() && permit_empty { - return Ok(s); - } else if s.is_empty() && !permit_empty { - if default.is_some() { - return Ok(default.unwrap()); - } else { - continue; - } - } else { - return Ok(s); - } - } -} - -pub fn ask_select_from_list(list: &[&str]) -> Result { - pick_from_list(default_menu_cmd().as_mut(), list, "Selection: ") - .context(err_msg("Unknown interaction error")) - .map_err(Error::from) -} - /// Helper function to print a imag question string. The `question` argument may not contain a /// trailing questionmark. /// @@ -191,7 +83,6 @@ mod test { use std::io::BufReader; use super::ask_bool_; - use super::ask_uint_; #[test] fn test_ask_bool_nodefault_yes() { @@ -313,64 +204,4 @@ mod test { assert!(true == ask_bool_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); } - #[test] - fn test_ask_uint_nodefault() { - let question = "Is this 1"; - let default = None; - let answers = "1"; - let mut sink: Vec = vec![]; - - assert!(1 == ask_uint_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); - } - - #[test] - fn test_ask_uint_default() { - let question = "Is this 1"; - let default = Some(1); - let answers = "1"; - let mut sink: Vec = vec![]; - - assert!(1 == ask_uint_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); - } - - #[test] - fn test_ask_uint_default_2_input_1() { - let question = "Is this 1"; - let default = Some(2); - let answers = "1"; - let mut sink: Vec = vec![]; - - assert!(1 == ask_uint_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); - } - - #[test] - fn test_ask_uint_default_2_noinput() { - let question = "Is this 1"; - let default = Some(2); - let answers = "\n"; - let mut sink: Vec = vec![]; - - assert!(2 == ask_uint_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); - } - - #[test] - fn test_ask_uint_default_2_several_noinput() { - let question = "Is this 1"; - let default = Some(2); - let answers = "\n\n\n\n"; - let mut sink: Vec = vec![]; - - assert!(2 == ask_uint_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); - } - - #[test] - fn test_ask_uint_default_2_wrong_input() { - let question = "Is this 1"; - let default = Some(2); - let answers = "\n\n\nasfb\nsakjf\naskjf\n-2"; - let mut sink: Vec = vec![]; - - assert!(2 == ask_uint_(question, default, &mut BufReader::new(answers.as_bytes()), &mut sink).unwrap()); - } - } From bce167d7402048cf650e94690a1daf3c00f25a48 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 22 May 2019 22:39:35 +0200 Subject: [PATCH 5/6] Update changelog for 0.9.2. Signed-off-by: Matthias Beyer (cherry picked from commit d828e5fd6ff2f13c0737260649c28a8fcaab6299) --- doc/src/09020-changelog.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index 0d41b5d6..715a4784 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -14,6 +14,17 @@ the changelog (though updating of dependencies is). Please note that we do not have a "Breaking changes" section as we are in Version 0.y.z and thus we can break the API like we want and need to. +## 0.9.2 + +Bugfix release for fixing: + +* Fix a function that checks a flag. If the flag is not there, it should be "not + set". +* Fix to not ignore errors when collecting links in libimagentrylink +* Remove buildscripts because imag was not installable from crates.io with + buildscripts. + + ## 0.9.1 Bugfix release for fixing: From d759e402a670437b723526de0645ec9ce4c95b3c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 22 May 2019 23:56:24 +0200 Subject: [PATCH 6/6] Add changelog for 0.9.3 Signed-off-by: Matthias Beyer (cherry picked from commit 6661b72e3d1a984f3010251698b7ee92be80af1a) --- doc/src/09020-changelog.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index 715a4784..023086c4 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -14,6 +14,16 @@ the changelog (though updating of dependencies is). Please note that we do not have a "Breaking changes" section as we are in Version 0.y.z and thus we can break the API like we want and need to. +## 0.9.3 + +Bugfix release for fixing: + +* Removed an import which was already there and fails with the current beta + compiler +* Fix a negation error in the config aggregation in imag-log +* Dependency specification fail in 0.9.2 where everything did not depend on + 0.9.2 but 0.9.1 + ## 0.9.2 Bugfix release for fixing: