summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-04-30 14:04:15 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-04-30 14:04:16 +0200
commit58a6eea573c6887921d7883ed009662439f87c66 (patch)
tree0c9bd9a90738b2538b30129f431837ef2540e39e /bin
parent76966bcd6c6e9c330cc97ad230e84f3dbddcba56 (diff)
Remove the edit command
The edit command of imag-diary gets removed by this patch. The rationale is that imag-edit is way more powerful and thus, not every other imag module should implement an edit command. Chaining `imag-diary list` and `imag edit -I` is encouraged. We still need the edit functionality in imag-diary, as `imag diary create` shall spawn an editor, still. We only remove the ability for editing of existing entries with this patch.
Diffstat (limited to 'bin')
-rw-r--r--bin/domain/imag-diary/src/edit.rs66
-rw-r--r--bin/domain/imag-diary/src/main.rs3
-rw-r--r--bin/domain/imag-diary/src/ui.rs13
3 files changed, 0 insertions, 82 deletions
diff --git a/bin/domain/imag-diary/src/edit.rs b/bin/domain/imag-diary/src/edit.rs
deleted file mode 100644
index 2c974056..00000000
--- a/bin/domain/imag-diary/src/edit.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// imag - the personal information management suite for the commandline
-// Copyright (C) 2015-2018 Matthias Beyer <mail@beyermatthias.de> 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 std::process::exit;
-
-use chrono::naive::NaiveDateTime;
-
-use libimagdiary::diary::Diary;
-use libimagdiary::diaryid::DiaryId;
-use libimagdiary::error::DiaryErrorKind as DEK;
-use libimagdiary::error::DiaryError as DE;
-use libimagdiary::error::ResultExt;
-use libimagentryedit::edit::Edit;
-use libimagrt::runtime::Runtime;
-use libimagerror::trace::MapErrTrace;
-use libimagtimeui::datetime::DateTime;
-use libimagtimeui::parse::Parse;
-use libimagutil::warn_exit::warn_exit;
-
-use util::get_diary_name;
-
-pub fn edit(rt: &Runtime) {
- let diaryname = get_diary_name(rt).unwrap_or_else(|| warn_exit("No diary name", 1));
-
- rt.cli()
- .subcommand_matches("edit")
- .unwrap()
- .value_of("datetime")
- .and_then(DateTime::parse)
- .map(|dt| dt.into())
- .map(|dt: NaiveDateTime| DiaryId::from_datetime(diaryname.clone(), dt))
- .or_else(|| {
- rt.store()
- .get_youngest_entry_id(&diaryname)
- .map(|o| o.map_err_trace_exit_unwrap(1))
- })
- .ok_or_else(|| {
- error!("No entries in diary. Aborting");
- exit(1)
- })
- .and_then(|id| rt.store().get(id))
- .map(|opte| match opte {
- Some(mut e) => e.edit_content(rt).chain_err(|| DEK::IOError),
- None => Err(DE::from_kind(DEK::EntryNotInDiary)),
- })
- .map_err_trace()
- .ok();
-}
-
-
diff --git a/bin/domain/imag-diary/src/main.rs b/bin/domain/imag-diary/src/main.rs
index ebf343d9..d48f0288 100644
--- a/bin/domain/imag-diary/src/main.rs
+++ b/bin/domain/imag-diary/src/main.rs
@@ -59,7 +59,6 @@ use itertools::Itertools;
mod create;
mod delete;
-mod edit;
mod list;
mod ui;
mod util;
@@ -67,7 +66,6 @@ mod view;
use create::create;
use delete::delete;
-use edit::edit;
use list::list;
use view::view;
@@ -86,7 +84,6 @@ fn main() {
"diaries" => diaries(&rt),
"create" => create(&rt),
"delete" => delete(&rt),
- "edit" => edit(&rt),
"list" => list(&rt),
"view" => view(&rt),
other => {
diff --git a/bin/domain/imag-diary/src/ui.rs b/bin/domain/imag-diary/src/ui.rs
index a5e54bc0..fe20ba12 100644
--- a/bin/domain/imag-diary/src/ui.rs
+++ b/bin/domain/imag-diary/src/ui.rs
@@ -77,19 +77,6 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.requires("timed"))
)
- .subcommand(SubCommand::with_name("edit")
- .about("Edit a diary entry")
- .version("0.1")
- .arg(Arg::with_name("datetime")
- .long("datetime")
- .short("d")
- .takes_value(true)
- .required(false)
- .help("Specify the date and time which entry should be edited. If none is
- specified, the last entry is edited. If the diary entry does not exist for
- this time, this fails. Format: YYYY-MM-DDT[HH[:mm[:ss]]]"))
- )
-
.subcommand(SubCommand::with_name("list")
.about("List diary entries")
.version("0.1"))