diff --git a/.imag-documentation/Cargo.toml b/.imag-documentation/Cargo.toml index 0d45f87b..5057179a 100644 --- a/.imag-documentation/Cargo.toml +++ b/.imag-documentation/Cargo.toml @@ -26,9 +26,6 @@ path = "../libimagentrylist" [dependencies.libimagentrymarkdown] path = "../libimagentrymarkdown" -[dependencies.libimagentryselect] -path = "../libimagentryselect" - [dependencies.libimagentrytag] path = "../libimagentrytag" diff --git a/.imag-documentation/src/lib.rs b/.imag-documentation/src/lib.rs index 2f50c33f..63eafb5f 100644 --- a/.imag-documentation/src/lib.rs +++ b/.imag-documentation/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + //! # imag //! //! This is the _developer_ documentation for the imag personal information management suite for the diff --git a/.travis.yml b/.travis.yml index 94325312..365c9971 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,49 +20,24 @@ before_script: export PATH=$HOME/.local/bin:$PATH script: - | - travis_cargo_run_in() { - echo ":: Trying to run cargo in $1" - [[ -d "$1" ]] && - cd "$1" && - { - { - if [[ $(echo "$1" | grep lib) ]]; then - travis-cargo -q test - else - travis-cargo -q build - fi - } && - cd - - } || exit 1 - } + if [[ "$TEST_SUITE" == "binaries" ]]; then + make bin-test + else # $TEST_SUITE == "libraries" + make lib-test + fi - run_sh_test() { - echo "--- Running test script: '$1'" - bash $1 || { echo "--- Test failed. Exiting"; exit 1; } - echo "--- Test script $1 executed successfully" - } - - echo "<< Changes in ./doc are not build by CI >>" - - for d in $(find -name "Cargo.toml" | grep -vE "^./Cargo.toml$"); do - echo ":: Working on $d" - dir=$(dirname $d) - { \ - echo -e "\n--- Running in $d ---\n" && \ - travis_cargo_run_in $dir && \ - echo "--- Running test scripts ---" && \ - for testsh in $(find $dir -iname "*test.sh"); do - run_sh_test $testsh - done && \ - echo -e "--- Done with test scripts ---\n\n" - } || true - done addons: apt: packages: + - cmake - libcurl4-openssl-dev - - libelf-dev - libdw-dev + - libelf-dev + - libzzip-dev + - make + - tree + sources: + - kalakris-cmake after_success: - | pushd .imag-documentation && @@ -78,6 +53,9 @@ notifications: template: - "%{repository_name} (%{branch} @ %{commit} by %{author}): %{result}" env: + matrix: + - TEST_SUITE=binaries + - TEST_SUITE=libraries global: - TRAVIS_CARGO_NIGHTLY_FEATURE=dev - secure: D+3exBnbvzFvk7fvLOxkF7UotCc4gBbvvOW4xGr9u6dDjEjV5y6CdDy/OQAkhfKhvSou+lIC22g5MuCBQXFEf/ua7A1XzwBAFeVLK4cWZSa7+ql6LdHKqOg3oF6pQlh095WeWr8S2PYJFFJFg8RGUPnbjqdu1J4KSXqe/7GoZ3lYS69mx7D5Hb93KEN084/KGfBuvyJtMjO1fK3spltL2zV8oqegFpv0gLG5GY4LsJ/7ij4Mc6wepXSyyQbaiA1eKMMwQZDvoi4V1mCulo/jeC3pucGxvgnMV5DZs8aa8R7votltGvSpHCgU78LW19dg8oZqwShQQ+XUYw27H+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9xhAIRgCui3kX/UDhmeME7nJI6k3UZydh+/ydNB1BZHTKn76XS/yFj0Gcibxg7f5fcAYA6Ge5Sg+YPozuwbcKnKe6IpN2M7qNgWa+6MCSXJ1v4BgPb7kN74EynJUM8+yWEFN7MZtWEUQ4ZsHdCs8Pub4C/zHpYGV8qGenZwQzosAFq56YwoGCvJezz35yg4BDd3IMKenOzNnXLBrdxxqX8ySgwt5B3zBqwve/64Lx6OXjae2m8wZKlsmeqad/s6K7nx0zG15/qqRIzyvgcLXq3jwBaHkteq49FRFWvHQFpBQcsPZ2uH4= diff --git a/Makefile b/Makefile index 1199a133..ad164ccc 100644 --- a/Makefile +++ b/Makefile @@ -4,21 +4,24 @@ bin = $@/target/debug/$@ doc-crate-toml=./.imag-documentation/Cargo.toml ECHO=$(shell which echo) -e +MAKE=$(shell which make) +BASH=$(shell which bash) CARGO=$(shell which cargo) -BINS=$(shell find -maxdepth 1 -name "imag-*" -type d) -LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d) +BINS=$(shell find -maxdepth 1 -name "imag-*" -type d | sort) +LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d | sort) BIN_TARGETS=$(patsubst imag-%,,$(BINS)) +BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test) LIB_TARGETS=$(LIBS) -LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),test-$(x)) +LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),$(x)-test) TARGETS=$(BIN_TARGETS) $(LIB_TARGETS) RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release) INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install) UPDATE_TARGETS=$(foreach x,$(TARGETS),$(x)-update) CLEAN_TARGETS=$(foreach x,$(TARGETS),$(x)-clean) -all: $(TARGETS) +all: $(TARGETS) imag-bin @$(ECHO) "\t[ALL ]" imag-bin: @@ -27,7 +30,7 @@ imag-bin: imag-bin-release: @$(ECHO) "\t[IMAG ][RELEASE]" - @$(CARGO) release --manifest-path ./bin/Cargo.toml + @$(CARGO) build --release --manifest-path ./bin/Cargo.toml imag-bin-update: @$(ECHO) "\t[IMAG ][UPDATE ]" @@ -47,15 +50,19 @@ release: $(RELEASE_TARGETS) imag-bin-release bin: $(BIN_TARGETS) imag-bin @$(ECHO) "\t[ALLBIN ]" +bin-test: $(BIN_TARGET_TESTS) + lib: $(LIB_TARGETS) @$(ECHO) "\t[ALLLIB ]" lib-test: $(LIB_TARGETS_TEST) -install: $(INSTALL_TARGETS) +test: bin-test lib-test + +install: $(INSTALL_TARGETS) imag-bin-install @$(ECHO) "\t[INSTALL]" -update: $(UPDATE_TARGETS) +update: $(UPDATE_TARGETS) imag-bin-update @$(ECHO) "\t[UPDATE ]" clean: $(CLEAN_TARGETS) imag-bin-clean @@ -65,13 +72,19 @@ $(TARGETS): %: .FORCE @$(ECHO) "\t[CARGO ]:\t$@" @$(CARGO) build --manifest-path ./$@/Cargo.toml +$(BIN_TARGET_TESTS): %-test: % .FORCE + @$(ECHO) "\t[BINTEST]:\t$@" + if [ -f $(subst -test,,$@)/tests/Makefile ]; then \ + $(MAKE) -C $(subst -test,,$@)/tests || exit 1;\ + fi; + $(RELEASE_TARGETS): %: .FORCE @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" @$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml $(LIB_TARGETS_TEST): %: .FORCE @$(ECHO) "\t[TEST ]:\t$@" - @$(CARGO) test --manifest-path ./$(subst test-,,$@)/Cargo.toml + @$(CARGO) test --manifest-path ./$(subst -test,,$@)/Cargo.toml $(INSTALL_TARGETS): %: .FORCE imag-bin-install @$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)" diff --git a/README.md b/README.md index 72c2fc11..ee8e5c8b 100644 --- a/README.md +++ b/README.md @@ -1,148 +1,95 @@ # imag - [imag-pim.org](http://imag-pim.org) -Imag is a CLI PIM suite you can -integrate in your tools of choice (Editor, MUA, RSS reader, etc etc). +`imag` is a commandline personal information management suite. + +**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.** [![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)]() -## Please contribute! +## What is this / Goal and Functionality -We are looking work contributors! +Our (long-term) goal is to -There is always a number of -[complexity/easy tagged issues](https://github.com/matthiasbeyer/imag/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity%2Feasy) -available in the issue tracker you can start with and we are open to questions! - -Feel free to open issues for asking questions, suggesting features or other -things! - -Also have a look at [the CONTRIBUTING.md file](./CONTRIBUTING.md)! - -## Goal - -Our goal is to - -> Create a fast, reliable, forwards/backwards compatible commandline personal +> Create a fast, reliable commandline personal > information management suite which covers all aspects of personal information > management, consists of reusable parts and integrates well with known > commandline tools. -We try to accomplish these requirements: +We try to implement as many aspects of personal information management (PIM), +but re-use existing commandline tools. +We do this by tracking/referring to the data the tools create. +A user can now link pieces of data (from different tools), tag this data and +query/search this data using imag. +So `imag` is more like a data-mining helper than an actual PIM tool, but we +implement some of the PIM aspects directly in `imag`. +Parts of PIM (we call them "modules") that are already implemented and basically +working: -* "fast": We use the awesome, fast and safe programming language "Rust" -* "reliable": We try to test every aspect of our software. Our build process - ensures that the build breaks whenever a library interface changes and the - modules which use the library are not updated. -* "forwards/backwards compatible:" Our (plain text) on-disk data format and - storage library both ensure that incompatibilities are captured and resolved - ([using](https://crates.io/crates/semver) [semver](https://semver.org)) -* "commandline": We ensure that everything can be done by commandline calls, for - some modules there might be a curses-like UI, but there are no graphical - clients and there never will be any within this codebase. We use - [clap](https://crates.io/crates/clap) for commandline-interface building and - we try to keep the interface easy and consistent between modules. -* "personal": We store everything as plain text in a store inside the users - `$HOME` directory. There will be a version-control (most surely `git`) hook - integrated to sync between several machines. There are no multi-user features - included or planned at the time of writing. -* "information management": We want to give the user the possibility to put - every single information about their personal lives into the store and we try - hard to provide a sane interface to query and retrieve data from this - database. -* "covers all the aspects of personal information management": We want to - provide modules for: - * contact management - * calendar - * diary - * notes - * personal wiki - * news (rss) - * passwords - * images - * music - * movies - * personal project management - * podcast management - * ledger - * mail - * bibliography management - * ... and many, many more. -* "constists of reusable parts": Every functionality is implemented as library. - The binaries we ship are just commandline-interace-to-library-interface - translators -* "integrates well with known commandline tools": We do not re-invent the wheel. - **We do not implement "yet another password manager", but use - [the standard unix password manager](https://www.passwordstore.org/), do not - implement a news reader, but use [newsbeuter](http://www.newsbeuter.org/), - do not reimplement a mail reader, etc etc.** - We do not copy images, movies or other data to the store but "link" them into - the store, so you can use imag tools to query and access this data, but still - live with your beloved commandline apps. We do not want to duplicate work but - reuse as much as possible. - You don't like one of the applications we use (for example `pass` as password - manager)? Sure, feel free to submit patches so the user is able to switch the - used tool, as long as it doesn't break the workflow. We will happily merge - them! +* todo (via taskwarrior, we track the tasks one creates in taskwarrior) +* diary +* notes +* bookmarks +* counter (just an example, nothing that usable) -## Current state of development +Helper modules that come with `imag` but are not "PIM aspects": -**This application is in _really_ early development.** - -We have implemented the very core of the system, though some more utility work -is to be done. -We have the store working, a hooks API and some default hooks are in -development. -Basic features like tagging and linking entries is possible as well as viewing -entries. -Some small things are implemented, like a note-taking module, a basic diary -module, a counter module and a bookmark module. -These modules contain basic features and are subject to change. -More modules are about to be implemented. - -Though, the very core of the system is stable and nothing prevents _you_ from -contributing and implementing a module. +* linking entries +* viewing entries +* tagging entries +* creating misc entries +* creating entries that refer to files/directories ## Building/Running -Here goes how to try imag out. +Here goes how to try `imag` out. + +`imag` is a _suite_ of tools and you can build them individually. +All subdirectories prefixed with "`libimag"` are libraries for the respective +binaries. +All subdirectories prefixed with `"imag-"` are binaries and compiling them will +give you a commandline application. ### Building By now, there are several targets in the Makefile, fulfilling following roles: -* `all` Is the default and builds every crate in debug mode. This is the same as - traversing every directory yourself and calling `cargo build` in it. - To build a single crate, call `make `, for example - `make imag-store` -* `release`, as the name implies, builds every crate in release mode. Following - the example above, to build `imag-store` in release mode, call - `make imag-store-release`. -* `install` will install all binary crates to the default installation root (see - `man cargo-install`). To install a single module, run `make -install`, - again, for example: `make imag-store-install` + +* `all` is the default and builds every crate in debug mode. + To build a single module, call `make `, for example `make imag-store`. +* `release`, as the name implies, builds every module in release mode. + E.G.: `make imag-store-release` to build "imag-store" in release mode. +* `install` will install all commandline modules to the default installation + root (see `man cargo-install`). + To install a single module, run `make -install`, + E.G.: `make imag-store-install` * `bin`/`lib` are separate targets for either building all binaries or libraries. -* `lib-test` runs `cargo test` for all libraries. For testing a single library, - run `make test-libimagstore` for example. -* `clean` will run `cargo clean` in every crate. Again, for cleaning a single - crate, use `make imag-store-clean` for example. +* `lib-test` runs `cargo test` for all libraries. + For testing a single library, E.G.: `make test-libimagstore`. +* `clean` will run `cargo clean` in every crate. + For cleaning a single crate, use `make imag-store-clean` for example. * to build _only_ the `imag` binary, use the target `imag-bin` - (`imag-bin-release` for release build, `imag-bin-update` for - `cargo update`ing, `imag-bin-clean` for `cargo clean`ing). + (`imag-bin-release` for release build, `imag-bin-clean` for `cargo clean`ing). ### Running To test out a single module, simply using `cargo run -- ` in the -respective directory will do the trick. For using it "normally", install the +respective directory will do the trick. +But you can also `make ` and call the binary on the commandline. +For using it "normally", install the binaries as described above, as well as the imag-binary: + ``` $> make install ``` -The installation root of the binaries (a.k.a. where they are installed to), may -not yet be in your $PATH. To see, where this installation root is, check out -`man cargo-install`. To change the $PATH in bash: + +The installation root of the binaries may not yet be in your $PATH. +To see where this installation root is check out `man cargo-install`. +To change the $PATH in bash: ```bash $> PATH=$PATH:~/.cargo/bin @@ -155,20 +102,46 @@ To test, simply add `--help` to one of the above commands: $> imag counter --help ``` -Please note that $PATH will be reset in a new shell. To make these changes -permanent, see the User Guide of your shell. +## Staying up-to-date + +Despite we have a [official site for imag](http://imag-pim.org), I do not push +updates to this site, yet. Anyways, I post a blog articles about what happened +in the last two weeks every other week. + +You can find them +[on my personal blog, tagged "imag"](http://beyermatthias.de/tags/imag.html) + +I also post these blog posts +[on reddit](https://www.reddit.com/r/rust/search?q=What%27s+coming+up+in+imag&restrict_sr=on) +and submit them to [this-week-in-rust](https://this-week-in-rust.org/). + +From time to time I publish an article about imag which does not focus on some +things that are happening, but rather about something more general. ## Documentation -For detailed information, please read [the documentation](./doc/) (You can -either read the Markdown files or compile it to HTML/PDF using -[pandoc](http://pandoc.org)). +For detailed information, please read [the documentation](./doc/). +You can either read the Markdown files or compile it to HTML/PDF using +[pandoc](http://pandoc.org). Developer documentation is also available [online on github.io](https://matthiasbeyer.github.io/imag/imag_documentation/index.html). Please note that the documentation is work in progress as well and may be outdated. +## Please contribute! + +We are looking for contributors! + +There is always a number of +[complexity/easy tagged issues](https://github.com/matthiasbeyer/imag/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity%2Feasy) +available in the issue tracker you can start with and we are open to questions! + +Feel free to open issues for asking questions, suggesting features or other +things! + +Also have a look at [the CONTRIBUTING.md file](./CONTRIBUTING.md)! + ## Contact Have a look at [our website](http://imag-pim.org) where you can find some diff --git a/bin/src/main.rs b/bin/src/main.rs index 71d56820..4d258e19 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + extern crate crossbeam; extern crate clap; #[macro_use] extern crate version; diff --git a/default.nix b/default.nix index 3a57f1cb..e7f4bc28 100644 --- a/default.nix +++ b/default.nix @@ -5,6 +5,12 @@ let rustc cargo ]; + + dependencies = with pkgs; [ + openssl + zlib + cmake + ]; in pkgs.stdenv.mkDerivation rec { @@ -12,7 +18,7 @@ pkgs.stdenv.mkDerivation rec { src = ./.; version = "0.0.0"; - buildInputs = [ env ]; + buildInputs = [ env dependencies ]; } diff --git a/doc/src/04020-module-tag.md b/doc/src/04020-module-tag.md index 9e644efd..08c66ecf 100644 --- a/doc/src/04020-module-tag.md +++ b/doc/src/04020-module-tag.md @@ -2,6 +2,8 @@ The Tagging module. +A valid tag matches the regex `[a-zA-Z][0-9a-zA-Z]*`. + ### Description diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index 06490c24..b23b7211 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + extern crate clap; #[macro_use] extern crate log; #[macro_use] extern crate version; diff --git a/imag-bookmark/src/ui.rs b/imag-bookmark/src/ui.rs index 701cdbba..0b142574 100644 --- a/imag-bookmark/src/ui.rs +++ b/imag-bookmark/src/ui.rs @@ -1,6 +1,26 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, SubCommand}; use libimagentrytag::ui::tag_add_arg; +use libimagutil::cli_validators::*; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app @@ -22,6 +42,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .required(true) .multiple(true) .value_name("URL") + .validator(is_url) .help("Add this URL, multiple possible")) .arg(tag_add_arg()) ) @@ -44,6 +65,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .required(true) .multiple(true) .value_name("URL") + .validator(is_url) .help("Remove these urls, regex supported")) ) diff --git a/imag-counter/src/create.rs b/imag-counter/src/create.rs index 9b455df5..9ef66387 100644 --- a/imag-counter/src/create.rs +++ b/imag-counter/src/create.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::str::FromStr; use libimagrt::runtime::Runtime; diff --git a/imag-counter/src/delete.rs b/imag-counter/src/delete.rs index 92bb543f..8a358284 100644 --- a/imag-counter/src/delete.rs +++ b/imag-counter/src/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagrt::runtime::Runtime; use libimagerror::trace::trace_error_exit; use libimagcounter::counter::Counter; diff --git a/imag-counter/src/interactive.rs b/imag-counter/src/interactive.rs index d37a0c05..c4a8fa65 100644 --- a/imag-counter/src/interactive.rs +++ b/imag-counter/src/interactive.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::collections::BTreeMap; use std::fmt::{Display, Formatter, Error}; use std::io::Write; diff --git a/imag-counter/src/list.rs b/imag-counter/src/list.rs index d18ae9b1..d8d3e86e 100644 --- a/imag-counter/src/list.rs +++ b/imag-counter/src/list.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagrt::runtime::Runtime; use libimagerror::trace::{MapErrTrace, trace_error}; use libimagcounter::counter::Counter; diff --git a/imag-counter/src/main.rs b/imag-counter/src/main.rs index c83bba0a..35a22441 100644 --- a/imag-counter/src/main.rs +++ b/imag-counter/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-counter/src/ui.rs b/imag-counter/src/ui.rs index 2218076e..2b928dd8 100644 --- a/imag-counter/src/ui.rs +++ b/imag-counter/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-diary/Cargo.toml b/imag-diary/Cargo.toml index 2d0df647..618b16e6 100644 --- a/imag-diary/Cargo.toml +++ b/imag-diary/Cargo.toml @@ -21,9 +21,6 @@ path = "../libimagentryedit" [dependencies.libimagentrylist] path = "../libimagentrylist" -[dependencies.libimagentryview] -path = "../libimagentryview" - [dependencies.libimagerror] path = "../libimagerror" diff --git a/imag-diary/src/create.rs b/imag-diary/src/create.rs index c715cfaf..78f679a7 100644 --- a/imag-diary/src/create.rs +++ b/imag-diary/src/create.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::process::exit; use libimagdiary::diary::Diary; diff --git a/imag-diary/src/delete.rs b/imag-diary/src/delete.rs index aec5a8eb..7325047b 100644 --- a/imag-diary/src/delete.rs +++ b/imag-diary/src/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; diff --git a/imag-diary/src/edit.rs b/imag-diary/src/edit.rs index 6c87d130..beed8c05 100644 --- a/imag-diary/src/edit.rs +++ b/imag-diary/src/edit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; diff --git a/imag-diary/src/list.rs b/imag-diary/src/list.rs index bae95ce4..4f1abc51 100644 --- a/imag-diary/src/list.rs +++ b/imag-diary/src/list.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagdiary::diary::Diary; use libimagdiary::error::DiaryErrorKind as DEK; use libimagdiary::error::MapErrInto; diff --git a/imag-diary/src/main.rs b/imag-diary/src/main.rs index 7a34f1ef..71e00cd6 100644 --- a/imag-diary/src/main.rs +++ b/imag-diary/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, @@ -21,7 +40,6 @@ extern crate chrono; extern crate libimagdiary; extern crate libimagentryedit; extern crate libimagentrylist; -extern crate libimagentryview; extern crate libimaginteraction; extern crate libimagrt; extern crate libimagstore; diff --git a/imag-diary/src/ui.rs b/imag-diary/src/ui.rs index a38060bd..91712fb6 100644 --- a/imag-diary/src/ui.rs +++ b/imag-diary/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, ArgGroup, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-diary/src/util.rs b/imag-diary/src/util.rs index 956062be..25498085 100644 --- a/imag-diary/src/util.rs +++ b/imag-diary/src/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagrt::runtime::Runtime; pub fn get_diary_name(rt: &Runtime) -> Option { diff --git a/imag-diary/src/view.rs b/imag-diary/src/view.rs index 742bc262..041a1fe0 100644 --- a/imag-diary/src/view.rs +++ b/imag-diary/src/view.rs @@ -1,30 +1,38 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagdiary::diary::Diary; -use libimagentryview::viewer::Viewer; -use libimagentryview::builtin::plain::PlainViewer; +use libimagdiary::viewer::DiaryViewer as DV; use libimagrt::runtime::Runtime; -use libimagerror::trace::trace_error; +use libimagerror::trace::MapErrTrace; use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn view(rt: &Runtime) { let diaryname = get_diary_name(rt).unwrap_or_else(|| warn_exit("No diary name", 1)); - let diary = Diary::open(rt.store(), &diaryname[..]); - let show_header = rt.cli().subcommand_matches("view").unwrap().is_present("show-header"); + let diary = Diary::open(rt.store(), &diaryname[..]); + let hdr = rt.cli().subcommand_matches("view").unwrap().is_present("show-header"); - match diary.entries() { - Ok(entries) => { - let pv = PlainViewer::new(show_header); - for entry in entries.into_iter().filter_map(Result::ok) { - let id = entry.diary_id(); - println!("{} :\n", id); - if let Err(e) = pv.view_entry(&entry) { - trace_error(&e); - }; - println!("\n---\n"); - } - }, - Err(e) => trace_error(&e), - } + diary.entries() + .and_then(|entries| DV::new(hdr).view_entries(entries.into_iter().filter_map(Result::ok))) + .map_err_trace() + .ok(); } diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index a30758e5..6734c3d4 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-link/src/ui.rs b/imag-link/src/ui.rs index b54c4982..4edb6bd1 100644 --- a/imag-link/src/ui.rs +++ b/imag-link/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, ArgGroup, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-link/tests/Makefile b/imag-link/tests/Makefile new file mode 100644 index 00000000..2713587a --- /dev/null +++ b/imag-link/tests/Makefile @@ -0,0 +1,13 @@ +ECHO=$(shell which echo) -e +TARGETS=$(shell find -name "*test.sh" -type f) +BASH=$(shell which bash) + +all: $(TARGETS) + @$(ECHO) $(TARGETS) + +$(TARGETS): %: .FORCE + @$(ECHO) "\t[BASH ]:\t$@" + @$(BASH) $@ + +.FORCE: + diff --git a/imag-notes/src/main.rs b/imag-notes/src/main.rs index 475847c0..dd24607c 100644 --- a/imag-notes/src/main.rs +++ b/imag-notes/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + extern crate clap; #[macro_use] extern crate log; extern crate semver; diff --git a/imag-notes/src/ui.rs b/imag-notes/src/ui.rs index 1c115853..906c5524 100644 --- a/imag-notes/src/ui.rs +++ b/imag-notes/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, SubCommand}; use libimagentrytag::ui::tag_argument; diff --git a/imag-ref/Cargo.toml b/imag-ref/Cargo.toml index da41fdcf..221615a2 100644 --- a/imag-ref/Cargo.toml +++ b/imag-ref/Cargo.toml @@ -27,3 +27,6 @@ path = "../libimaginteraction" [dependencies.libimagentrylist] path = "../libimagentrylist" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index fd29a4a6..f7212b46 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #[macro_use] extern crate log; #[macro_use] extern crate version; extern crate semver; @@ -9,6 +28,7 @@ extern crate libimagref; extern crate libimagerror; extern crate libimagentrylist; extern crate libimaginteraction; +extern crate libimagutil; mod ui; use ui::build_ui; diff --git a/imag-ref/src/ui.rs b/imag-ref/src/ui.rs index e884c90f..5c4685e2 100644 --- a/imag-ref/src/ui.rs +++ b/imag-ref/src/ui.rs @@ -1,5 +1,26 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, SubCommand}; +use libimagutil::cli_validators::is_existing_path; + pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app .subcommand(SubCommand::with_name("add") @@ -11,6 +32,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .takes_value(true) .required(true) .help("The path of the file") + .validator(is_existing_path) .value_name("PATH")) .arg(Arg::with_name("track-content") .long("content-hash") diff --git a/imag-store/src/create.rs b/imag-store/src/create.rs index 0380ddf5..cfdbd01b 100644 --- a/imag-store/src/create.rs +++ b/imag-store/src/create.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use std::io::stdin; use std::fs::OpenOptions; diff --git a/imag-store/src/delete.rs b/imag-store/src/delete.rs index 885a089c..1413de77 100644 --- a/imag-store/src/delete.rs +++ b/imag-store/src/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use libimagrt::runtime::Runtime; diff --git a/imag-store/src/error.rs b/imag-store/src/error.rs index ae9162f0..bc248ade 100644 --- a/imag-store/src/error.rs +++ b/imag-store/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(StoreError, StoreErrorKind, BackendError => "Backend Error", diff --git a/imag-store/src/get.rs b/imag-store/src/get.rs index 1302b763..0c2aa132 100644 --- a/imag-store/src/get.rs +++ b/imag-store/src/get.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use libimagrt::runtime::Runtime; diff --git a/imag-store/src/main.rs b/imag-store/src/main.rs index 56c46241..7d2f46e9 100644 --- a/imag-store/src/main.rs +++ b/imag-store/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-store/src/retrieve.rs b/imag-store/src/retrieve.rs index 41f8e936..4d17e817 100644 --- a/imag-store/src/retrieve.rs +++ b/imag-store/src/retrieve.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use clap::ArgMatches; diff --git a/imag-store/src/ui.rs b/imag-store/src/ui.rs index a317a445..fc493c9c 100644 --- a/imag-store/src/ui.rs +++ b/imag-store/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-store/src/update.rs b/imag-store/src/update.rs index 87279dc0..bdcfb6de 100644 --- a/imag-store/src/update.rs +++ b/imag-store/src/update.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::DerefMut; use std::path::PathBuf; diff --git a/imag-store/src/util.rs b/imag-store/src/util.rs index 197f2846..8e7002c9 100644 --- a/imag-store/src/util.rs +++ b/imag-store/src/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::borrow::Cow; use std::collections::btree_map::{BTreeMap, Entry}; use std::str::Split; diff --git a/imag-store/src/verify.rs b/imag-store/src/verify.rs index b22d5909..6c9cb703 100644 --- a/imag-store/src/verify.rs +++ b/imag-store/src/verify.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagrt::runtime::Runtime; use libimagutil::warn_exit::warn_exit; diff --git a/imag-store/tests/Makefile b/imag-store/tests/Makefile new file mode 100644 index 00000000..c58562d7 --- /dev/null +++ b/imag-store/tests/Makefile @@ -0,0 +1,14 @@ +ECHO=$(shell which echo) -e +TARGETS=$(shell find -name "*test.sh" -type f) +BASH=$(shell which bash) + +all: $(TARGETS) + @$(ECHO) $(TARGETS) + +$(TARGETS): %: .FORCE + @$(ECHO) "\t[BASH ]:\t$@" + @$(BASH) $@ + +.FORCE: + + diff --git a/imag-tag/src/main.rs b/imag-tag/src/main.rs index 92d3b7f3..3e8d7daa 100644 --- a/imag-tag/src/main.rs +++ b/imag-tag/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + extern crate clap; #[macro_use] extern crate log; extern crate semver; diff --git a/imag-tag/src/ui.rs b/imag-tag/src/ui.rs index 1355344a..ee9b6feb 100644 --- a/imag-tag/src/ui.rs +++ b/imag-tag/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, ArgGroup, SubCommand}; use libimagentrytag::ui::{tag_add_arg, tag_remove_arg}; diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index a5ca650e..bcdae191 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + extern crate clap; extern crate glob; #[macro_use] extern crate log; diff --git a/imag-todo/src/ui.rs b/imag-todo/src/ui.rs index f781673e..795c76c6 100644 --- a/imag-todo/src/ui.rs +++ b/imag-todo/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-view/src/editor.rs b/imag-view/src/editor.rs index 6a60b007..bbd255f7 100644 --- a/imag-view/src/editor.rs +++ b/imag-view/src/editor.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::FileLockEntry; use libimagrt::runtime::Runtime; use libimagentryview::builtin::editor::EditorView; diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs index ae9d5d29..b9f1d059 100644 --- a/imag-view/src/main.rs +++ b/imag-view/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, @@ -48,14 +67,6 @@ fn main() { let view_header = rt.cli().is_present("view-header"); let view_content = rt.cli().is_present("view-content"); - let scmd = match rt.cli().subcommand_matches("view-in") { - None => { - debug!("No commandline call"); - exit(1); // we can afford not-executing destructors here - } - Some(s) => s, - }; - let entry = match rt.store().get(PathBuf::from(entry_id)) { Ok(Some(fle)) => fle, Ok(None) => { @@ -68,19 +79,27 @@ fn main() { }; let res = { - if scmd.is_present("view-in-stdout") { - } else if scmd.is_present("view-in-ui") { - warn!("Viewing in UI is currently not supported, switch to stdout"); - } else if scmd.is_present("view-in-browser") { - warn!("Viewing in browser is currently not supported, switch to stdout"); - } else if scmd.is_present("view-in-texteditor") { - if let Err(e) = Editor::new(&rt, &entry).show() { - error!("Cannot view in editor: {}", e); - trace_error_exit(&e, 1); - } - } else if scmd.is_present("view-in-custom") { - warn!("Viewing in custom is currently not supported, switch to stdout"); - } + match rt.cli().subcommand_matches("view-in") { + None => { + debug!("No commandline call"); + debug!("Assuming to view in cli (stdout)"); + }, + Some(s) => { + if s.is_present("view-in-stdout") { + } else if s.is_present("view-in-ui") { + warn!("Viewing in UI is currently not supported, switch to stdout"); + } else if s.is_present("view-in-browser") { + warn!("Viewing in browser is currently not supported, switch to stdout"); + } else if s.is_present("view-in-texteditor") { + if let Err(e) = Editor::new(&rt, &entry).show() { + error!("Cannot view in editor: {}", e); + trace_error_exit(&e, 1); + } + } else if s.is_present("view-in-custom") { + warn!("Viewing in custom is currently not supported, switch to stdout"); + } + }, + }; StdoutViewer::new(view_header, view_content).view_entry(&entry) }; diff --git a/imag-view/src/ui.rs b/imag-view/src/ui.rs index b1081e86..dd165850 100644 --- a/imag-view/src/ui.rs +++ b/imag-view/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { @@ -50,12 +69,11 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .value_name("BROWSER")) .arg(Arg::with_name("view-in-texteditor") - .long("editor") + .long("in-editor") .short("e") - .takes_value(true) // optional, which editor + .takes_value(false) .required(false) - .help("View content in $EDITOR") - .value_name("EDITOR")) + .help("View content in $EDITOR (can be passed via --editor)")) .arg(Arg::with_name("view-in-custom") .long("custom") diff --git a/imagrc.toml b/imagrc.toml index 82a2dae3..5dbbf9fc 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -12,25 +12,91 @@ implicit-create = false # store, so these hooks should be chosen carefully. store-unload-hook-aspects = [ "debug" ] -pre-create-hook-aspects = [ "debug" ] -post-create-hook-aspects = [ "debug" ] +pre-create-hook-aspects = [ "debug", "vcs" ] +post-create-hook-aspects = [ "debug", "vcs" ] pre-move-hook-aspects = [ "debug" ] post-move-hook-aspects = [ "debug" ] -pre-retrieve-hook-aspects = [ "debug" ] -post-retrieve-hook-aspects = [ "debug" ] +pre-retrieve-hook-aspects = [ "debug", "vcs" ] +post-retrieve-hook-aspects = [ "debug", "vcs" ] -pre-update-hook-aspects = [ "debug" ] -post-update-hook-aspects = [ "debug" ] +pre-update-hook-aspects = [ "debug", "vcs" ] +post-update-hook-aspects = [ "debug", "vcs" ] -pre-delete-hook-aspects = [ "debug" ] -post-delete-hook-aspects = [ "debug" ] +pre-delete-hook-aspects = [ "debug", "vcs" ] +post-delete-hook-aspects = [ "debug", "vcs" ] [store.aspects.debug] parallel = false mutable_hooks = true +[store.aspects.vcs] +parallel = false +mutable_hooks = false + [store.hooks.stdhook_debug] aspect = "debug" +[store.hooks.stdhook_git_update] +aspect = "vcs" + +# set to false to disable +enabled = true + +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true + +# Ensure to be on this branche before doing anything. +ensure_branch = "refs/heads/master" + +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + +# Commit configuration +[store.hooks.stdhook_git_update.commit] + +# Whether to do the commit interactively +interactive = false + +# Set to true to use the $EDITOR for the commit, to false to do on commandline +# When committing without editor, only a single line is allowed as commit +# message +interactive_editor = false + +# Commit message if the commit is not interactive +message = "Update" + +[store.hooks.stdhook_git_delete] +aspect = "vcs" + +# set to false to disable +enabled = true + +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true + +# Ensure to be on this branche before doing anything. +ensure_branch = "refs/heads/master" + +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + +# Commit configuration +[store.hooks.stdhook_git_delete.commit] + +# Whether to do the commit interactively +interactive = false + +# Set to true to use the $EDITOR for the commit, to false to do on commandline +# When committing without editor, only a single line is allowed as commit +# message +interactive_editor = false + +# Commit message if the commit is not interactive +message = "Deleted" + diff --git a/libimagbookmark/src/collection.rs b/libimagbookmark/src/collection.rs index b2cde9ef..59d95e72 100644 --- a/libimagbookmark/src/collection.rs +++ b/libimagbookmark/src/collection.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + //! BookmarkCollection module //! //! A BookmarkCollection is nothing more than a simple store entry. One can simply call functions diff --git a/libimagbookmark/src/error.rs b/libimagbookmark/src/error.rs index 79849d9e..9b52a169 100644 --- a/libimagbookmark/src/error.rs +++ b/libimagbookmark/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(BookmarkError, BookmarkErrorKind, StoreReadError => "Store read error", diff --git a/libimagbookmark/src/lib.rs b/libimagbookmark/src/lib.rs index bc98b061..6b7de0dc 100644 --- a/libimagbookmark/src/lib.rs +++ b/libimagbookmark/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagbookmark/src/link.rs b/libimagbookmark/src/link.rs index 078d45d7..1da91c8a 100644 --- a/libimagbookmark/src/link.rs +++ b/libimagbookmark/src/link.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::{Deref, DerefMut}; use result::Result; diff --git a/libimagbookmark/src/result.rs b/libimagbookmark/src/result.rs index 265fec97..780a8035 100644 --- a/libimagbookmark/src/result.rs +++ b/libimagbookmark/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::BookmarkError; diff --git a/libimagcounter/src/counter.rs b/libimagcounter/src/counter.rs index e6a6e309..12bc0a93 100644 --- a/libimagcounter/src/counter.rs +++ b/libimagcounter/src/counter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::DerefMut; use toml::Value; diff --git a/libimagcounter/src/error.rs b/libimagcounter/src/error.rs index e151c407..c886d901 100644 --- a/libimagcounter/src/error.rs +++ b/libimagcounter/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(CounterError, CounterErrorKind, StoreIdError => "StoreId error", diff --git a/libimagcounter/src/lib.rs b/libimagcounter/src/lib.rs index 75340ad6..3ad74aa9 100644 --- a/libimagcounter/src/lib.rs +++ b/libimagcounter/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagcounter/src/result.rs b/libimagcounter/src/result.rs index 91a26599..e24b90c9 100644 --- a/libimagcounter/src/result.rs +++ b/libimagcounter/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::CounterError; diff --git a/libimagdiary/Cargo.toml b/libimagdiary/Cargo.toml index 5ac1b268..3f921ade 100644 --- a/libimagdiary/Cargo.toml +++ b/libimagdiary/Cargo.toml @@ -27,3 +27,6 @@ path = "../libimagrt" [dependencies.libimagentryedit] path = "../libimagentryedit" +[dependencies.libimagentryview] +path = "../libimagentryview" + diff --git a/libimagdiary/src/config.rs b/libimagdiary/src/config.rs index 93749289..b2e976a6 100644 --- a/libimagdiary/src/config.rs +++ b/libimagdiary/src/config.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 toml::Value; use libimagrt::runtime::Runtime; diff --git a/libimagdiary/src/diary.rs b/libimagdiary/src/diary.rs index de8571f9..1a19b052 100644 --- a/libimagdiary/src/diary.rs +++ b/libimagdiary/src/diary.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::cmp::Ordering; use libimagstore::store::Store; diff --git a/libimagdiary/src/diaryid.rs b/libimagdiary/src/diaryid.rs index 74c78309..ad91ccf3 100644 --- a/libimagdiary/src/diaryid.rs +++ b/libimagdiary/src/diaryid.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::convert::Into; use std::fmt::{Display, Formatter, Error as FmtError}; diff --git a/libimagdiary/src/entry.rs b/libimagdiary/src/entry.rs index c042fd91..0148b59d 100644 --- a/libimagdiary/src/entry.rs +++ b/libimagdiary/src/entry.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::Deref; use std::ops::DerefMut; diff --git a/libimagdiary/src/error.rs b/libimagdiary/src/error.rs index 5cb37915..b6dc2bfd 100644 --- a/libimagdiary/src/error.rs +++ b/libimagdiary/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(DiaryError, DiaryErrorKind, StoreWriteError => "Error writing store", @@ -7,7 +26,8 @@ generate_error_module!( DiaryEditError => "Cannot edit diary entry", PathConversionError => "Error while converting paths internally", EntryNotInDiary => "Entry not in Diary", - IOError => "IO Error" + IOError => "IO Error", + ViewError => "Error viewing diary entry" ); ); diff --git a/libimagdiary/src/is_in_diary.rs b/libimagdiary/src/is_in_diary.rs index 2b9d3fc7..09228072 100644 --- a/libimagdiary/src/is_in_diary.rs +++ b/libimagdiary/src/is_in_diary.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use libimagstore::storeid::StoreId; diff --git a/libimagdiary/src/iter.rs b/libimagdiary/src/iter.rs index 5146e5a7..73f180d2 100644 --- a/libimagdiary/src/iter.rs +++ b/libimagdiary/src/iter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::fmt::{Debug, Formatter, Error as FmtError}; use std::result::Result as RResult; diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs index 5af7eb50..f6756225 100644 --- a/libimagdiary/src/lib.rs +++ b/libimagdiary/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( dead_code, non_camel_case_types, @@ -26,6 +45,7 @@ extern crate itertools; #[macro_use] extern crate libimagutil; #[macro_use] extern crate libimagerror; extern crate libimagentryedit; +extern crate libimagentryview; extern crate libimagrt; module_entry_path_mod!("diary"); @@ -38,3 +58,5 @@ pub mod is_in_diary; pub mod entry; pub mod iter; pub mod result; +pub mod viewer; + diff --git a/libimagdiary/src/result.rs b/libimagdiary/src/result.rs index 5348c44b..b4f5f382 100644 --- a/libimagdiary/src/result.rs +++ b/libimagdiary/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::DiaryError; diff --git a/libimagdiary/src/viewer.rs b/libimagdiary/src/viewer.rs new file mode 100644 index 00000000..93b155a7 --- /dev/null +++ b/libimagdiary/src/viewer.rs @@ -0,0 +1,64 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + +//! A diary viewer built on libimagentryview. + +use entry::Entry; +use error::DiaryErrorKind as DEK; +use error::MapErrInto; +use result::Result; + +use libimagentryview::viewer::Viewer; +use libimagentryview::builtin::plain::PlainViewer; + +/// This viewer does _not_ implement libimagentryview::viewer::Viewer because we need to be able to +/// call some diary-type specific functions on the entries passed to this. +/// +/// This type is mainly just written to be constructed-called-deleted in one go: +/// +/// ```ignore +/// DiaryViewer::new(show_header).view_entries(entries); +/// ``` +/// +pub struct DiaryViewer(PlainViewer); + +impl DiaryViewer { + + pub fn new(show_header: bool) -> DiaryViewer { + DiaryViewer(PlainViewer::new(show_header)) + } + + /// View all entries from the iterator, or stop immediately if an error occurs, returning that + /// error. + pub fn view_entries<'a, I: Iterator>>(&self, entries: I) -> Result<()> { + for entry in entries { + let id = entry.diary_id(); + println!("{} :\n", id); + let _ = try!(self.0 + .view_entry(&entry) + .map_err_into(DEK::ViewError) + .map_err_into(DEK::IOError)); + println!("\n---\n"); + } + + Ok(()) + } + +} + diff --git a/libimagentryedit/Cargo.toml b/libimagentryedit/Cargo.toml index 0c79700e..076519fe 100644 --- a/libimagentryedit/Cargo.toml +++ b/libimagentryedit/Cargo.toml @@ -4,7 +4,6 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] -tempfile = "2.1.1" [dependencies.libimagerror] path = "../libimagerror" @@ -15,3 +14,6 @@ path = "../libimagrt" [dependencies.libimagstore] path = "../libimagstore" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagentryedit/src/edit.rs b/libimagentryedit/src/edit.rs index cdf976a4..f83c51c5 100644 --- a/libimagentryedit/src/edit.rs +++ b/libimagentryedit/src/edit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::DerefMut; use libimagerror::into::IntoError; @@ -39,39 +58,20 @@ impl<'a> Edit for FileLockEntry<'a> { } pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { - use tempfile::NamedTempFile; - use std::io::Seek; - use std::io::Read; - use std::io::SeekFrom; - use std::io::Write; + use libimagutil::edit::edit_in_tmpfile_with_command; - let file = try!(NamedTempFile::new().map_err_into(EditErrorKind::IOError)); - let file_path = file.path(); - let mut file = try!(file.reopen().map_err_into(EditErrorKind::IOError)); - - try!(file.write_all(&s.clone().into_bytes()[..]).map_err_into(EditErrorKind::IOError)); - try!(file.sync_data().map_err_into(EditErrorKind::IOError)); - - if let Some(mut editor) = rt.editor() { - let exit_status = editor.arg(file_path).status(); - - match exit_status.map(|s| s.success()).map_err(Box::new) { - Ok(true) => { - file.sync_data() - .and_then(|_| file.seek(SeekFrom::Start(0))) - .and_then(|_| { - let mut new_s = String::new(); - let res = file.read_to_string(&mut new_s); - *s = new_s; - res - }) - .map(|_| ()) - .map_err_into(EditErrorKind::IOError) - }, - Ok(false) => Err(EditErrorKind::ProcessExitFailure.into()), - Err(e) => Err(EditErrorKind::IOError.into_error_with_cause(e)), - } - } else { - Err(EditErrorKind::InstantiateError.into()) - } + rt.editor() + .ok_or(EditErrorKind::NoEditor.into_error()) + .and_then(|editor| { + edit_in_tmpfile_with_command(editor, s) + .map_err_into(EditErrorKind::IOError) + .and_then(|worked| { + if !worked { + Err(EditErrorKind::ProcessExitFailure.into()) + } else { + Ok(()) + } + }) + }) } + diff --git a/libimagentryedit/src/error.rs b/libimagentryedit/src/error.rs index 0cd675e0..478d5d2c 100644 --- a/libimagentryedit/src/error.rs +++ b/libimagentryedit/src/error.rs @@ -1,6 +1,26 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(EditError, EditErrorKind, IOError => "IO Error", + NoEditor => "No editor set", ProcessExitFailure => "Process did not exit properly", InstantiateError => "Instantation error" ); diff --git a/libimagentryedit/src/lib.rs b/libimagentryedit/src/lib.rs index 62cff1e4..00013d5e 100644 --- a/libimagentryedit/src/lib.rs +++ b/libimagentryedit/src/lib.rs @@ -1,7 +1,26 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #[macro_use] extern crate libimagerror; extern crate libimagstore; extern crate libimagrt; -extern crate tempfile; +extern crate libimagutil; pub mod edit; pub mod error; diff --git a/libimagentryedit/src/result.rs b/libimagentryedit/src/result.rs index 7e58f0fe..1d917c05 100644 --- a/libimagentryedit/src/result.rs +++ b/libimagentryedit/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::EditError; diff --git a/libimagentryfilter/src/builtin/bool_filter.rs b/libimagentryfilter/src/builtin/bool_filter.rs index a25f8159..e903e341 100644 --- a/libimagentryfilter/src/builtin/bool_filter.rs +++ b/libimagentryfilter/src/builtin/bool_filter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use filters::filter::Filter; diff --git a/libimagentryfilter/src/builtin/content/grep.rs b/libimagentryfilter/src/builtin/content/grep.rs index de8ade9b..02039fba 100644 --- a/libimagentryfilter/src/builtin/content/grep.rs +++ b/libimagentryfilter/src/builtin/content/grep.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 filters::filter::Filter; use regex::Regex; use regex::Error as RError; diff --git a/libimagentryfilter/src/builtin/content/length/is_over.rs b/libimagentryfilter/src/builtin/content/length/is_over.rs index 1ef51ab9..96f22da4 100644 --- a/libimagentryfilter/src/builtin/content/length/is_over.rs +++ b/libimagentryfilter/src/builtin/content/length/is_over.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 filters::filter::Filter; use libimagstore::store::Entry; diff --git a/libimagentryfilter/src/builtin/content/length/is_under.rs b/libimagentryfilter/src/builtin/content/length/is_under.rs index 5ae7fe7f..a365438e 100644 --- a/libimagentryfilter/src/builtin/content/length/is_under.rs +++ b/libimagentryfilter/src/builtin/content/length/is_under.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 filters::filter::Filter; use libimagstore::store::Entry; diff --git a/libimagentryfilter/src/builtin/content/length/mod.rs b/libimagentryfilter/src/builtin/content/length/mod.rs index 94121f96..2ebb18cb 100644 --- a/libimagentryfilter/src/builtin/content/length/mod.rs +++ b/libimagentryfilter/src/builtin/content/length/mod.rs @@ -1,2 +1,21 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod is_over; pub mod is_under; diff --git a/libimagentryfilter/src/builtin/content/mod.rs b/libimagentryfilter/src/builtin/content/mod.rs index b0ec6127..2ccbdf66 100644 --- a/libimagentryfilter/src/builtin/content/mod.rs +++ b/libimagentryfilter/src/builtin/content/mod.rs @@ -1,2 +1,21 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod grep; pub mod length; diff --git a/libimagentryfilter/src/builtin/header/field_eq.rs b/libimagentryfilter/src/builtin/header/field_eq.rs index 457f42b0..f10f3d0f 100644 --- a/libimagentryfilter/src/builtin/header/field_eq.rs +++ b/libimagentryfilter/src/builtin/header/field_eq.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_exists.rs b/libimagentryfilter/src/builtin/header/field_exists.rs index 721b7e0e..9999b3df 100644 --- a/libimagentryfilter/src/builtin/header/field_exists.rs +++ b/libimagentryfilter/src/builtin/header/field_exists.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_grep.rs b/libimagentryfilter/src/builtin/header/field_grep.rs index ce312b02..799fee68 100644 --- a/libimagentryfilter/src/builtin/header/field_grep.rs +++ b/libimagentryfilter/src/builtin/header/field_grep.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 regex::Regex; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/field_gt.rs b/libimagentryfilter/src/builtin/header/field_gt.rs index 02786901..2c1bcf89 100644 --- a/libimagentryfilter/src/builtin/header/field_gt.rs +++ b/libimagentryfilter/src/builtin/header/field_gt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_isempty.rs b/libimagentryfilter/src/builtin/header/field_isempty.rs index e8ea94c3..d243d78f 100644 --- a/libimagentryfilter/src/builtin/header/field_isempty.rs +++ b/libimagentryfilter/src/builtin/header/field_isempty.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_istype.rs b/libimagentryfilter/src/builtin/header/field_istype.rs index 13e6b325..889c8321 100644 --- a/libimagentryfilter/src/builtin/header/field_istype.rs +++ b/libimagentryfilter/src/builtin/header/field_istype.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_lt.rs b/libimagentryfilter/src/builtin/header/field_lt.rs index 9f6fae9a..0316bf82 100644 --- a/libimagentryfilter/src/builtin/header/field_lt.rs +++ b/libimagentryfilter/src/builtin/header/field_lt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_path.rs b/libimagentryfilter/src/builtin/header/field_path.rs index b61f32b9..42ba65aa 100644 --- a/libimagentryfilter/src/builtin/header/field_path.rs +++ b/libimagentryfilter/src/builtin/header/field_path.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub type FieldPath = String; diff --git a/libimagentryfilter/src/builtin/header/field_predicate.rs b/libimagentryfilter/src/builtin/header/field_predicate.rs index 1415b901..361ed0fe 100644 --- a/libimagentryfilter/src/builtin/header/field_predicate.rs +++ b/libimagentryfilter/src/builtin/header/field_predicate.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/mod.rs b/libimagentryfilter/src/builtin/header/mod.rs index 0d27f5b4..cb363c24 100644 --- a/libimagentryfilter/src/builtin/header/mod.rs +++ b/libimagentryfilter/src/builtin/header/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod field_eq; pub mod field_exists; pub mod field_grep; diff --git a/libimagentryfilter/src/builtin/header/version/eq.rs b/libimagentryfilter/src/builtin/header/version/eq.rs index acf75495..ac805a68 100644 --- a/libimagentryfilter/src/builtin/header/version/eq.rs +++ b/libimagentryfilter/src/builtin/header/version/eq.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 semver::Version; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/version/gt.rs b/libimagentryfilter/src/builtin/header/version/gt.rs index cc5dcade..daded755 100644 --- a/libimagentryfilter/src/builtin/header/version/gt.rs +++ b/libimagentryfilter/src/builtin/header/version/gt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 semver::Version; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/version/lt.rs b/libimagentryfilter/src/builtin/header/version/lt.rs index b7232c4c..02c35cd3 100644 --- a/libimagentryfilter/src/builtin/header/version/lt.rs +++ b/libimagentryfilter/src/builtin/header/version/lt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 semver::Version; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/version/mod.rs b/libimagentryfilter/src/builtin/header/version/mod.rs index a2e86826..e214e329 100644 --- a/libimagentryfilter/src/builtin/header/version/mod.rs +++ b/libimagentryfilter/src/builtin/header/version/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod eq; pub mod gt; pub mod lt; diff --git a/libimagentryfilter/src/builtin/header/version/range.rs b/libimagentryfilter/src/builtin/header/version/range.rs index 66ccbcd8..59f3a1d5 100644 --- a/libimagentryfilter/src/builtin/header/version/range.rs +++ b/libimagentryfilter/src/builtin/header/version/range.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 semver::Version; use libimagstore::store::Entry; diff --git a/libimagentryfilter/src/builtin/mod.rs b/libimagentryfilter/src/builtin/mod.rs index be547532..68c819bc 100644 --- a/libimagentryfilter/src/builtin/mod.rs +++ b/libimagentryfilter/src/builtin/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod content; pub mod header; diff --git a/libimagentryfilter/src/cli.rs b/libimagentryfilter/src/cli.rs index e69de29b..ee8b8381 100644 --- a/libimagentryfilter/src/cli.rs +++ b/libimagentryfilter/src/cli.rs @@ -0,0 +1,19 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + diff --git a/libimagentryfilter/src/lib.rs b/libimagentryfilter/src/lib.rs index 03cb114d..a481d125 100644 --- a/libimagentryfilter/src/lib.rs +++ b/libimagentryfilter/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentryfilter/src/tags/mod.rs b/libimagentryfilter/src/tags/mod.rs index 162e9824..cef11e5e 100644 --- a/libimagentryfilter/src/tags/mod.rs +++ b/libimagentryfilter/src/tags/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use libimagentrytag::tagable::Tagable; use libimagentrytag::tag::Tag; diff --git a/libimagentrylink/src/error.rs b/libimagentrylink/src/error.rs index 9c756c3b..7665da4d 100644 --- a/libimagentrylink/src/error.rs +++ b/libimagentrylink/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(LinkError, LinkErrorKind, EntryHeaderReadError => "Error while reading an entry header", diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index 45972bf5..f68028ff 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + /// External linking is a complex implementation to be able to serve a clean and easy-to-use /// interface. /// diff --git a/libimagentrylink/src/internal.rs b/libimagentrylink/src/internal.rs index 54d2b7de..f8320cd3 100644 --- a/libimagentrylink/src/internal.rs +++ b/libimagentrylink/src/internal.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::cmp::Ordering; use libimagstore::storeid::StoreId; diff --git a/libimagentrylink/src/lib.rs b/libimagentrylink/src/lib.rs index 804916fc..31442503 100644 --- a/libimagentrylink/src/lib.rs +++ b/libimagentrylink/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentrylink/src/result.rs b/libimagentrylink/src/result.rs index 587c0cac..23e50363 100644 --- a/libimagentrylink/src/result.rs +++ b/libimagentrylink/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::LinkError; diff --git a/libimagentrylist/src/cli.rs b/libimagentrylist/src/cli.rs index 5a04a21a..b52a92fd 100644 --- a/libimagentrylist/src/cli.rs +++ b/libimagentrylist/src/cli.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, ArgMatches, App, SubCommand}; use libimagstore::store::FileLockEntry; diff --git a/libimagentrylist/src/error.rs b/libimagentrylist/src/error.rs index 32e19f43..9c3b1ccc 100644 --- a/libimagentrylist/src/error.rs +++ b/libimagentrylist/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(ListError, ListErrorKind, IOError => "IO Error", diff --git a/libimagentrylist/src/lib.rs b/libimagentrylist/src/lib.rs index 8c6b8869..ee97d72c 100644 --- a/libimagentrylist/src/lib.rs +++ b/libimagentrylist/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagentrylist/src/lister.rs b/libimagentrylist/src/lister.rs index 80f86110..798061b8 100644 --- a/libimagentrylist/src/lister.rs +++ b/libimagentrylist/src/lister.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::FileLockEntry; use result::Result; diff --git a/libimagentrylist/src/listers/core.rs b/libimagentrylist/src/listers/core.rs index f2f83eea..733ba719 100644 --- a/libimagentrylist/src/listers/core.rs +++ b/libimagentrylist/src/listers/core.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::stdout; use std::io::Write; diff --git a/libimagentrylist/src/listers/line.rs b/libimagentrylist/src/listers/line.rs index 536d2039..66181542 100644 --- a/libimagentrylist/src/listers/line.rs +++ b/libimagentrylist/src/listers/line.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::stdout; use std::io::Write; diff --git a/libimagentrylist/src/listers/mod.rs b/libimagentrylist/src/listers/mod.rs index 4c43b657..78a6e8f7 100644 --- a/libimagentrylist/src/listers/mod.rs +++ b/libimagentrylist/src/listers/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod core; pub mod line; pub mod path; diff --git a/libimagentrylist/src/listers/path.rs b/libimagentrylist/src/listers/path.rs index cfe67b65..284ff1b3 100644 --- a/libimagentrylist/src/listers/path.rs +++ b/libimagentrylist/src/listers/path.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::stdout; use std::io::Write; diff --git a/libimagentrylist/src/listers/table.rs b/libimagentrylist/src/listers/table.rs index 231f708d..e9358ce3 100644 --- a/libimagentrylist/src/listers/table.rs +++ b/libimagentrylist/src/listers/table.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::stdout; use lister::Lister; diff --git a/libimagentrylist/src/result.rs b/libimagentrylist/src/result.rs index 729cce41..e29d7d34 100644 --- a/libimagentrylist/src/result.rs +++ b/libimagentrylist/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::ListError; diff --git a/libimagentrymarkdown/src/error.rs b/libimagentrymarkdown/src/error.rs index 3e42e21b..1186d5f3 100644 --- a/libimagentrymarkdown/src/error.rs +++ b/libimagentrymarkdown/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(MarkdownError, MarkdownErrorKind, MarkdownRenderError => "Markdown render error", diff --git a/libimagentrymarkdown/src/html.rs b/libimagentrymarkdown/src/html.rs index f9d251a8..e0a7b8b9 100644 --- a/libimagentrymarkdown/src/html.rs +++ b/libimagentrymarkdown/src/html.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 hoedown::{Markdown, Html as MdHtml}; use hoedown::renderer::html::Flags as HtmlFlags; use hoedown::renderer::Render; diff --git a/libimagentrymarkdown/src/lib.rs b/libimagentrymarkdown/src/lib.rs index d5d23410..d04680b7 100644 --- a/libimagentrymarkdown/src/lib.rs +++ b/libimagentrymarkdown/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentrymarkdown/src/link.rs b/libimagentrymarkdown/src/link.rs index 8ac3500c..267ef344 100644 --- a/libimagentrymarkdown/src/link.rs +++ b/libimagentrymarkdown/src/link.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 error::MarkdownErrorKind as MEK; use result::Result; diff --git a/libimagentrymarkdown/src/result.rs b/libimagentrymarkdown/src/result.rs index 55aa68e5..f00a3122 100644 --- a/libimagentrymarkdown/src/result.rs +++ b/libimagentrymarkdown/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::MarkdownError; diff --git a/libimagentryselect/Cargo.toml b/libimagentryselect/Cargo.toml deleted file mode 100644 index 19424a2c..00000000 --- a/libimagentryselect/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "libimagentryselect" -version = "0.2.0" -authors = ["Matthias Beyer "] - -[dependencies] -clap = "2.*" -log = "0.3" -interactor = "0.1" - -[dependencies.libimagstore] -path = "../libimagstore" - -[dependencies.libimagerror] -path = "../libimagerror" - diff --git a/libimagentryselect/README.md b/libimagentryselect/README.md deleted file mode 100644 index de6c4825..00000000 --- a/libimagentryselect/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# libimagentryselect - -Small library crate for asking the user to _select_ one or more entries out of -a list of entries. - -Not much functionality, yet. - diff --git a/libimagentryselect/src/error.rs b/libimagentryselect/src/error.rs deleted file mode 100644 index 767779e6..00000000 --- a/libimagentryselect/src/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -generate_error_module!( - generate_error_types!(EntrySelectError, EntrySelectErrorKind, - CLIError => "Error on commandline", - IdMissingError => "Commandline: ID missing", - StoreIdParsingError => "Error while parsing StoreId", - IdSelectingError => "Error while selecting id" - ); -); - -pub use self::error::EntrySelectError; -pub use self::error::EntrySelectErrorKind; -pub use self::error::MapErrInto; - diff --git a/libimagentryselect/src/lib.rs b/libimagentryselect/src/lib.rs deleted file mode 100644 index 8f5bcbd3..00000000 --- a/libimagentryselect/src/lib.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![deny( - non_camel_case_types, - non_snake_case, - path_statements, - trivial_numeric_casts, - unstable_features, - unused_allocation, - unused_import_braces, - unused_imports, - unused_mut, - unused_qualifications, - while_true, -)] - -extern crate clap; -extern crate log; -extern crate interactor; - -extern crate libimagstore; -#[macro_use] -extern crate libimagerror; - -pub mod error; -pub mod result; -pub mod ui; - diff --git a/libimagentryselect/src/result.rs b/libimagentryselect/src/result.rs deleted file mode 100644 index db949cf6..00000000 --- a/libimagentryselect/src/result.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std::result::Result as RResult; - -use error::EntrySelectError; - -pub type Result = RResult; - diff --git a/libimagentrytag/src/error.rs b/libimagentrytag/src/error.rs index 06f08797..579e3ce8 100644 --- a/libimagentrytag/src/error.rs +++ b/libimagentrytag/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(TagError, TagErrorKind, TagTypeError => "Entry Header Tag Type wrong", diff --git a/libimagentrytag/src/exec.rs b/libimagentrytag/src/exec.rs index 8ea45142..216e2c28 100644 --- a/libimagentrytag/src/exec.rs +++ b/libimagentrytag/src/exec.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::ArgMatches; use libimagstore::store::FileLockEntry; diff --git a/libimagentrytag/src/lib.rs b/libimagentrytag/src/lib.rs index 87e4fe87..d8931e40 100644 --- a/libimagentrytag/src/lib.rs +++ b/libimagentrytag/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentrytag/src/result.rs b/libimagentrytag/src/result.rs index a01166ca..02d72766 100644 --- a/libimagentrytag/src/result.rs +++ b/libimagentrytag/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::TagError; diff --git a/libimagentrytag/src/tag.rs b/libimagentrytag/src/tag.rs index ec72161c..28ecd934 100644 --- a/libimagentrytag/src/tag.rs +++ b/libimagentrytag/src/tag.rs @@ -1,2 +1,21 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub type Tag = String; pub type TagSlice<'a> = &'a str; diff --git a/libimagentrytag/src/tagable.rs b/libimagentrytag/src/tagable.rs index df49f763..21e7c5ec 100644 --- a/libimagentrytag/src/tagable.rs +++ b/libimagentrytag/src/tagable.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::Deref; use std::ops::DerefMut; diff --git a/libimagentrytag/src/ui.rs b/libimagentrytag/src/ui.rs index e74b1ac9..dad4c87e 100644 --- a/libimagentrytag/src/ui.rs +++ b/libimagentrytag/src/ui.rs @@ -1,7 +1,28 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::{Arg, ArgMatches, App, SubCommand}; use tag::Tag; +use libimagutil::cli_validators::is_tag; + /// Generates a `clap::SubCommand` to be integrated in the commandline-ui builder for building a /// "tags --add foo --remove bar" subcommand to do tagging action. pub fn tag_subcommand<'a, 'b>() -> App<'a, 'b> { @@ -20,6 +41,7 @@ pub fn tag_add_arg<'a, 'b>() -> Arg<'a, 'b> { .takes_value(true) .value_name("tags") .multiple(true) + .validator(is_tag) .help("Add tags, seperated by comma or by specifying multiple times") } @@ -30,6 +52,7 @@ pub fn tag_remove_arg<'a, 'b>() -> Arg<'a, 'b> { .takes_value(true) .value_name("tags") .multiple(true) + .validator(is_tag) .help("Remove tags, seperated by comma or by specifying multiple times") } @@ -57,6 +80,7 @@ pub fn tag_argument<'a, 'b>() -> Arg<'a, 'b> { .long("tags") .takes_value(true) .multiple(true) + .validator(is_tag) .help("Add or remove tags, prefixed by '+' (for adding) or '-' (for removing)") } diff --git a/libimagentrytag/src/util.rs b/libimagentrytag/src/util.rs index 16b76a1d..d0d31db2 100644 --- a/libimagentrytag/src/util.rs +++ b/libimagentrytag/src/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 regex::Regex; pub fn is_tag(s: &str) -> bool { diff --git a/libimagentryview/src/builtin/editor.rs b/libimagentryview/src/builtin/editor.rs index d13c1fb4..259d4986 100644 --- a/libimagentryview/src/builtin/editor.rs +++ b/libimagentryview/src/builtin/editor.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use libimagrt::runtime::Runtime; use libimagentryedit::edit::edit_in_tmpfile; diff --git a/libimagentryview/src/builtin/mod.rs b/libimagentryview/src/builtin/mod.rs index 657f5e80..26d5b223 100644 --- a/libimagentryview/src/builtin/mod.rs +++ b/libimagentryview/src/builtin/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod editor; pub mod plain; pub mod stdout; diff --git a/libimagentryview/src/builtin/plain.rs b/libimagentryview/src/builtin/plain.rs index 02ff5fc8..d96f4604 100644 --- a/libimagentryview/src/builtin/plain.rs +++ b/libimagentryview/src/builtin/plain.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use viewer::Viewer; diff --git a/libimagentryview/src/builtin/stdout.rs b/libimagentryview/src/builtin/stdout.rs index 7f6a8b28..703281fd 100644 --- a/libimagentryview/src/builtin/stdout.rs +++ b/libimagentryview/src/builtin/stdout.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use toml::encode_str; diff --git a/libimagentryview/src/error.rs b/libimagentryview/src/error.rs index fbc31487..c471b3f3 100644 --- a/libimagentryview/src/error.rs +++ b/libimagentryview/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(ViewError, ViewErrorKind, Unknown => "Unknown view error", diff --git a/libimagentryview/src/lib.rs b/libimagentryview/src/lib.rs index 534b05f3..788eb49c 100644 --- a/libimagentryview/src/lib.rs +++ b/libimagentryview/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagentryview/src/result.rs b/libimagentryview/src/result.rs index 4d5786fa..3650b1fe 100644 --- a/libimagentryview/src/result.rs +++ b/libimagentryview/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::ViewError; diff --git a/libimagentryview/src/viewer.rs b/libimagentryview/src/viewer.rs index 72ffbd7d..35763126 100644 --- a/libimagentryview/src/viewer.rs +++ b/libimagentryview/src/viewer.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagstore::store::Entry; use result::Result; diff --git a/libimagerror/src/error_gen.rs b/libimagerror/src/error_gen.rs index 236251e0..e46ce184 100644 --- a/libimagerror/src/error_gen.rs +++ b/libimagerror/src/error_gen.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #[macro_export] macro_rules! generate_error_imports { () => { diff --git a/libimagerror/src/into.rs b/libimagerror/src/into.rs index a959abd4..bc3cfb41 100644 --- a/libimagerror/src/into.rs +++ b/libimagerror/src/into.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::error::Error; /// Trait to help converting Error kinds into Error instances diff --git a/libimagerror/src/lib.rs b/libimagerror/src/lib.rs index 34d4758c..5046ba5a 100644 --- a/libimagerror/src/lib.rs +++ b/libimagerror/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagerror/src/trace.rs b/libimagerror/src/trace.rs index 30687eeb..3fbc4faf 100644 --- a/libimagerror/src/trace.rs +++ b/libimagerror/src/trace.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::error::Error; use std::io::Write; use std::io::stderr; diff --git a/libimaginteraction/Cargo.toml b/libimaginteraction/Cargo.toml index 7a78df33..d13b2823 100644 --- a/libimaginteraction/Cargo.toml +++ b/libimaginteraction/Cargo.toml @@ -4,12 +4,13 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] -spinner = "0.4" -interactor = "0.1" -log = "0.3" ansi_term = "0.7.2" -regex = "0.1" +clap = "2.*" +interactor = "0.1" lazy_static = "0.1.15" +log = "0.3" +regex = "0.1" +spinner = "0.4" [dependencies.libimagstore] path = "../libimagstore" diff --git a/libimaginteraction/src/ask.rs b/libimaginteraction/src/ask.rs index b85ac837..30f4b26c 100644 --- a/libimaginteraction/src/ask.rs +++ b/libimaginteraction/src/ask.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + // functions to ask the user for data, with crate:spinner use std::io::stdin; diff --git a/libimaginteraction/src/error.rs b/libimaginteraction/src/error.rs index 9285f0fd..5ac3b730 100644 --- a/libimaginteraction/src/error.rs +++ b/libimaginteraction/src/error.rs @@ -1,9 +1,33 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(InteractionError, InteractionErrorKind, - Unknown => "Unknown Error" + Unknown => "Unknown Error", + CLIError => "Error on commandline", + IdMissingError => "Commandline: ID missing", + StoreIdParsingError => "Error while parsing StoreId", + IdSelectingError => "Error while selecting id" ); ); pub use self::error::InteractionError; pub use self::error::InteractionErrorKind; +pub use self::error::MapErrInto; diff --git a/libimaginteraction/src/filter.rs b/libimaginteraction/src/filter.rs index 875eb0ec..5869a529 100644 --- a/libimaginteraction/src/filter.rs +++ b/libimaginteraction/src/filter.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + // A filter which uses crate:interactor to filter entries diff --git a/libimaginteraction/src/lib.rs b/libimaginteraction/src/lib.rs index a608898f..07d458bd 100644 --- a/libimaginteraction/src/lib.rs +++ b/libimaginteraction/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, @@ -18,6 +37,7 @@ extern crate interactor; extern crate ansi_term; #[macro_use] extern crate lazy_static; extern crate regex; +extern crate clap; extern crate libimagentryfilter; extern crate libimagstore; @@ -28,4 +48,5 @@ pub mod ask; pub mod error; pub mod filter; pub mod result; +pub mod ui; diff --git a/libimaginteraction/src/result.rs b/libimaginteraction/src/result.rs index f3d63482..8eeaf47b 100644 --- a/libimaginteraction/src/result.rs +++ b/libimaginteraction/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::InteractionError; diff --git a/libimagentryselect/src/ui.rs b/libimaginteraction/src/ui.rs similarity index 55% rename from libimagentryselect/src/ui.rs rename to libimaginteraction/src/ui.rs index e3e41b8a..49c4619d 100644 --- a/libimagentryselect/src/ui.rs +++ b/libimaginteraction/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use clap::{Arg, ArgMatches}; @@ -7,7 +26,7 @@ use libimagerror::into::IntoError; use result::Result; use error::MapErrInto; -use error::EntrySelectErrorKind as ESEK; +use error::InteractionErrorKind as IEK; pub fn id_argument<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name(id_argument_name()) @@ -33,14 +52,14 @@ pub fn id_argument_long() -> &'static str { pub fn get_id(matches: &ArgMatches) -> Result> { matches .values_of(id_argument_name()) - .ok_or(ESEK::IdMissingError.into_error()) - .map_err_into(ESEK::CLIError) + .ok_or(IEK::IdMissingError.into_error()) + .map_err_into(IEK::CLIError) .and_then(|vals| { vals.into_iter() .fold(Ok(vec![]), |acc, elem| { acc.and_then(|mut v| { let elem = StoreId::new_baseless(PathBuf::from(String::from(elem))); - let elem = try!(elem.map_err_into(ESEK::StoreIdParsingError)); + let elem = try!(elem.map_err_into(IEK::StoreIdParsingError)); v.push(elem); Ok(v) }) @@ -51,12 +70,12 @@ pub fn get_id(matches: &ArgMatches) -> Result> { pub fn get_or_select_id(matches: &ArgMatches, store_path: &PathBuf) -> Result> { use interactor::{pick_file, default_menu_cmd}; - match get_id(matches).map_err_into(ESEK::IdSelectingError) { + match get_id(matches).map_err_into(IEK::IdSelectingError) { Ok(v) => Ok(v), Err(_) => { let path = store_path.clone(); - let p = try!(pick_file(default_menu_cmd, path).map_err_into(ESEK::IdSelectingError)); - let id = try!(StoreId::new_baseless(p).map_err_into(ESEK::StoreIdParsingError)); + let p = try!(pick_file(default_menu_cmd, path).map_err_into(IEK::IdSelectingError)); + let id = try!(StoreId::new_baseless(p).map_err_into(IEK::StoreIdParsingError)); Ok(vec![id]) }, } diff --git a/libimagnotes/src/error.rs b/libimagnotes/src/error.rs index bebed316..9fd51218 100644 --- a/libimagnotes/src/error.rs +++ b/libimagnotes/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(NoteError, NoteErrorKind, StoreWriteError => "Error writing store", diff --git a/libimagnotes/src/lib.rs b/libimagnotes/src/lib.rs index 7abc5eb3..10ef952b 100644 --- a/libimagnotes/src/lib.rs +++ b/libimagnotes/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagnotes/src/note.rs b/libimagnotes/src/note.rs index 768b5607..2397948c 100644 --- a/libimagnotes/src/note.rs +++ b/libimagnotes/src/note.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::collections::BTreeMap; use std::ops::Deref; diff --git a/libimagnotes/src/result.rs b/libimagnotes/src/result.rs index df40d8c7..a11ba895 100644 --- a/libimagnotes/src/result.rs +++ b/libimagnotes/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::NoteError; diff --git a/libimagref/src/error.rs b/libimagref/src/error.rs index b0aaacf3..b1e5e2c5 100644 --- a/libimagref/src/error.rs +++ b/libimagref/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(RefError, RefErrorKind, StoreReadError => "Store read error", diff --git a/libimagref/src/flags.rs b/libimagref/src/flags.rs index 00bfcf2b..11cd838d 100644 --- a/libimagref/src/flags.rs +++ b/libimagref/src/flags.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::collections::BTreeMap; use toml::Value; diff --git a/libimagref/src/hasher.rs b/libimagref/src/hasher.rs index fcdda5bd..d29502d2 100644 --- a/libimagref/src/hasher.rs +++ b/libimagref/src/hasher.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use std::io::Read; diff --git a/libimagref/src/hashers/mod.rs b/libimagref/src/hashers/mod.rs index c5c49799..eaa8de3f 100644 --- a/libimagref/src/hashers/mod.rs +++ b/libimagref/src/hashers/mod.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub mod nbytes; diff --git a/libimagref/src/hashers/nbytes.rs b/libimagref/src/hashers/nbytes.rs index 66af0297..995e3dd8 100644 --- a/libimagref/src/hashers/nbytes.rs +++ b/libimagref/src/hashers/nbytes.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::Read; use std::path::PathBuf; use std::result::Result as RResult; diff --git a/libimagref/src/lib.rs b/libimagref/src/lib.rs index fb4814c9..402eac27 100644 --- a/libimagref/src/lib.rs +++ b/libimagref/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagref/src/lister.rs b/libimagref/src/lister.rs index 979984a2..326a764f 100644 --- a/libimagref/src/lister.rs +++ b/libimagref/src/lister.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::default::Default; use std::io::stdout; use std::io::Write; diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 15a89734..63ca6a39 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + //! The Ref object is a helper over the link functionality, so one is able to create references to //! files outside of the imag store. diff --git a/libimagref/src/result.rs b/libimagref/src/result.rs index 097232d5..eefcec65 100644 --- a/libimagref/src/result.rs +++ b/libimagref/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; use error::RefError; diff --git a/libimagrt/src/configuration.rs b/libimagrt/src/configuration.rs index 71056901..52e51b24 100644 --- a/libimagrt/src/configuration.rs +++ b/libimagrt/src/configuration.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use std::result::Result as RResult; use std::ops::Deref; diff --git a/libimagrt/src/error.rs b/libimagrt/src/error.rs index e5f26baa..388335af 100644 --- a/libimagrt/src/error.rs +++ b/libimagrt/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_imports!(); use std::io::Error as IOError; diff --git a/libimagrt/src/lib.rs b/libimagrt/src/lib.rs index 2aea566b..13c004ba 100644 --- a/libimagrt/src/lib.rs +++ b/libimagrt/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagrt/src/logger.rs b/libimagrt/src/logger.rs index f5b6ad76..2e6244f8 100644 --- a/libimagrt/src/logger.rs +++ b/libimagrt/src/logger.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::Write; use std::io::stderr; diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index e847631d..60f81d16 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use std::process::Command; use std::env; @@ -43,6 +62,8 @@ impl<'a> Runtime<'a> { use libimagstore::hook::Hook; use libimagstore::error::StoreErrorKind; use libimagstorestdhook::debug::DebugHook; + use libimagstorestdhook::vcs::git::delete::DeleteHook as GitDeleteHook; + use libimagstorestdhook::vcs::git::update::UpdateHook as GitUpdateHook; use libimagerror::trace::trace_error; use libimagerror::trace::trace_error_dbg; use libimagerror::into::IntoError; @@ -107,7 +128,7 @@ impl<'a> Runtime<'a> { write!(stderr(), "Store-config: {:?}\n", store_config).ok(); } - Store::new(storepath, store_config).map(|mut store| { + Store::new(storepath.clone(), store_config).map(|mut store| { // If we are debugging, generate hooks for all positions if is_debugging { let hooks : Vec<(Box, &str, HP)> = vec![ @@ -134,6 +155,24 @@ impl<'a> Runtime<'a> { } } + let sp = storepath; + + let hooks : Vec<(Box, &str, HP)> = vec![ + (Box::new(GitDeleteHook::new(sp.clone(), HP::PostDelete)) , "vcs", HP::PostDelete), + (Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate), + ]; + + for (hook, aspectname, position) in hooks { + if let Err(e) = store.register_hook(position, &String::from(aspectname), hook) { + if e.err_type() == StoreErrorKind::HookRegisterError { + trace_error_dbg(&e); + warn!("Registering git hook with store failed"); + } else { + trace_error(&e); + }; + } + } + Runtime { cli_matches: matches, configuration: cfg, diff --git a/libimagrt/src/setup.rs b/libimagrt/src/setup.rs index 620a81cf..735a8883 100644 --- a/libimagrt/src/setup.rs +++ b/libimagrt/src/setup.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::App; use runtime::Runtime; diff --git a/libimagstore/src/configuration.rs b/libimagstore/src/configuration.rs index c450000c..eb9bd196 100644 --- a/libimagstore/src/configuration.rs +++ b/libimagstore/src/configuration.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 toml::Value; use libimagerror::into::IntoError; diff --git a/libimagstore/src/error.rs b/libimagstore/src/error.rs index 80c10a0c..09ed092f 100644 --- a/libimagstore/src/error.rs +++ b/libimagstore/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_imports!(); use std::convert::From; diff --git a/libimagstore/src/file_abstraction.rs b/libimagstore/src/file_abstraction.rs index 1b9e6790..9a190842 100644 --- a/libimagstore/src/file_abstraction.rs +++ b/libimagstore/src/file_abstraction.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub use self::fs::FileAbstraction; // TODO: diff --git a/libimagstore/src/hook/accessor.rs b/libimagstore/src/hook/accessor.rs index b36d1ff4..8bcca25b 100644 --- a/libimagstore/src/hook/accessor.rs +++ b/libimagstore/src/hook/accessor.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::fmt::Debug; use hook::result::HookResult; diff --git a/libimagstore/src/hook/aspect.rs b/libimagstore/src/hook/aspect.rs index bd493122..40dc6085 100644 --- a/libimagstore/src/hook/aspect.rs +++ b/libimagstore/src/hook/aspect.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 libimagerror::trace::trace_error; use libimagutil::iter::FoldResult; @@ -68,10 +87,6 @@ impl MutableHookDataAccessor for Aspect { fn access_mut(&self, fle: &mut FileLockEntry) -> HookResult<()> { debug!("Checking whether mutable hooks are allowed"); debug!("-> config = {:?}", self.cfg); - if !self.cfg.as_ref().map(|c| c.allow_mutable_hooks()).unwrap_or(false) { - debug!("Apparently mutable hooks are not allowed... failing now."); - return Err(HE::new(HEK::MutableHooksNotAllowed, None)); - } let accessors : Vec = self.hooks.iter().map(|h| h.accessor()).collect(); @@ -82,8 +97,15 @@ impl MutableHookDataAccessor for Aspect { accessors.iter().fold_defresult(|accessor| { let res = match accessor { &HDA::StoreIdAccess(ref accessor) => accessor.access(fle.get_location()), - &HDA::MutableAccess(ref accessor) => accessor.access_mut(fle), &HDA::NonMutableAccess(ref accessor) => accessor.access(fle), + &HDA::MutableAccess(ref accessor) => { + if !self.cfg.as_ref().map(|c| c.allow_mutable_hooks()).unwrap_or(false) { + debug!("Apparently mutable hooks are not allowed... failing now."); + return Err(HE::new(HEK::MutableHooksNotAllowed, None)); + } + + accessor.access_mut(fle) + }, }; trace_hook_errors(res) }) diff --git a/libimagstore/src/hook/error.rs b/libimagstore/src/hook/error.rs index a576b931..0d890bf3 100644 --- a/libimagstore/src/hook/error.rs +++ b/libimagstore/src/hook/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::default::Default; generate_error_imports!(); diff --git a/libimagstore/src/hook/mod.rs b/libimagstore/src/hook/mod.rs index 43b81de3..5c8e50f2 100644 --- a/libimagstore/src/hook/mod.rs +++ b/libimagstore/src/hook/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::fmt::Debug; use toml::Value; diff --git a/libimagstore/src/hook/position.rs b/libimagstore/src/hook/position.rs index 0ccb563e..8b9f9264 100644 --- a/libimagstore/src/hook/position.rs +++ b/libimagstore/src/hook/position.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #[derive(Debug, Clone)] pub enum HookPosition { StoreUnload, diff --git a/libimagstore/src/hook/result.rs b/libimagstore/src/hook/result.rs index 11766624..e25c7220 100644 --- a/libimagstore/src/hook/result.rs +++ b/libimagstore/src/hook/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 hook::error::HookError; pub type HookResult = Result; diff --git a/libimagstore/src/lib.rs b/libimagstore/src/lib.rs index 9268594e..08eb0afa 100644 --- a/libimagstore/src/lib.rs +++ b/libimagstore/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 283938b2..bbf3e85e 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::collections::HashMap; use std::ops::Drop; use std::path::PathBuf; @@ -500,21 +519,7 @@ impl Store { /// Return the `FileLockEntry` and write to disk pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> { - if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), &mut entry) { - return Err(e) - .map_err_into(SEK::PreHookExecuteError) - .map_err_into(SEK::HookExecutionError) - .map_err_into(SEK::UpdateCallError); - } - - if let Err(e) = self._update(&entry, false) { - return Err(e).map_err_into(SEK::UpdateCallError); - } - - self.execute_hooks_for_mut_file(self.post_update_aspects.clone(), &mut entry) - .map_err_into(SEK::PostHookExecuteError) - .map_err_into(SEK::HookExecutionError) - .map_err_into(SEK::UpdateCallError) + self._update(&mut entry, false).map_err_into(SEK::UpdateCallError) } /// Internal method to write to the filesystem store. @@ -522,7 +527,13 @@ impl Store { /// # Assumptions /// This method assumes that entry is dropped _right after_ the call, hence /// it is not public. - fn _update<'a>(&'a self, entry: &FileLockEntry<'a>, modify_presence: bool) -> Result<()> { + fn _update<'a>(&'a self, mut entry: &mut FileLockEntry<'a>, modify_presence: bool) -> Result<()> { + let _ = try!(self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), &mut entry) + .map_err_into(SEK::PreHookExecuteError) + .map_err_into(SEK::HookExecutionError) + .map_err_into(SEK::UpdateCallError) + ); + let mut hsmap = match self.entries.write() { Err(_) => return Err(SE::new(SEK::LockPoisoned, None)), Ok(e) => e, @@ -541,7 +552,11 @@ impl Store { se.status = StoreEntryStatus::Present; } - Ok(()) + + self.execute_hooks_for_mut_file(self.post_update_aspects.clone(), &mut entry) + .map_err_into(SEK::PostHookExecuteError) + .map_err_into(SEK::HookExecutionError) + .map_err_into(SEK::UpdateCallError) } /// Retrieve a copy of a given entry, this cannot be used to mutate @@ -938,7 +953,7 @@ impl<'a> Drop for FileLockEntry<'a> { impl<'a> Drop for FileLockEntry<'a> { /// This will not silently ignore errors but prints the result of the _update() call for testing fn drop(&mut self) { - println!("Drop Result: {:?}", self.store._update(self, true)); + let _ = self.store._update(self, true).map_err(|e| trace_error(&e)); } } diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index a5c2c11e..5f979126 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::ops::Deref; use std::path::Path; use std::path::PathBuf; @@ -75,10 +94,6 @@ impl StoreId { self.clone().into_pathbuf().map(|pb| pb.exists()).unwrap_or(false) } - pub fn is_file(&self) -> bool { - true - } - pub fn to_str(&self) -> Result { if self.base.is_some() { let mut base = self.base.as_ref().cloned().unwrap(); diff --git a/libimagstorestdhook/Cargo.toml b/libimagstorestdhook/Cargo.toml index b9bda7f3..912079b2 100644 --- a/libimagstorestdhook/Cargo.toml +++ b/libimagstorestdhook/Cargo.toml @@ -7,6 +7,7 @@ authors = ["Matthias Beyer "] toml = "0.2.*" log = "0.3" fs2 = "0.2" +git2 = "0.4" [dependencies.libimagstore] path = "../libimagstore" @@ -14,6 +15,12 @@ path = "../libimagstore" [dependencies.libimagentrylink] path = "../libimagentrylink" +[dependencies.libimaginteraction] +path = "../libimaginteraction" + [dependencies.libimagerror] path = "../libimagerror" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagstorestdhook/src/debug.rs b/libimagstorestdhook/src/debug.rs index ef63b015..af20f330 100644 --- a/libimagstorestdhook/src/debug.rs +++ b/libimagstorestdhook/src/debug.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 toml::Value; use libimagstore::hook::Hook; diff --git a/libimagstorestdhook/src/flock.rs b/libimagstorestdhook/src/flock.rs index 07c90a74..6cc30864 100644 --- a/libimagstorestdhook/src/flock.rs +++ b/libimagstorestdhook/src/flock.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 toml::Value; use fs2::FileExt; diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index bb01b9c5..fe5e4ebc 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( dead_code, non_camel_case_types, @@ -17,12 +36,16 @@ #[macro_use] extern crate log; extern crate toml; extern crate fs2; +extern crate git2; extern crate libimagstore; extern crate libimagentrylink; +extern crate libimaginteraction; #[macro_use] extern crate libimagerror; +extern crate libimagutil; pub mod debug; pub mod flock; pub mod linkverify; +pub mod vcs; diff --git a/libimagstorestdhook/src/linkverify.rs b/libimagstorestdhook/src/linkverify.rs index 85551999..3b3c3cea 100644 --- a/libimagstorestdhook/src/linkverify.rs +++ b/libimagstorestdhook/src/linkverify.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; use toml::Value; @@ -55,8 +74,6 @@ impl NonMutableHookDataAccessor for LinkedEntriesExistHook { for link in links { if !link.exists() { warn!("File link does not exist: {:?} -> {:?}", fle.get_location(), link); - } else if !link.is_file() { - warn!("File link is not a file: {:?} -> {:?}", fle.get_location(), link); } } }) diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs new file mode 100644 index 00000000..76ea91b8 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -0,0 +1,65 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::fmt::{Display, Formatter, Error}; + +/// Utility type to specify which kind of store action is running +#[derive(Clone, Debug)] +pub enum StoreAction { + Create, + Retrieve, + Update, + Delete, +} + +impl StoreAction { + + pub fn uppercase(&self) -> &str { + match *self { + StoreAction::Create => "CREATE", + StoreAction::Retrieve => "RETRIEVE", + StoreAction::Update => "UPDATE", + StoreAction::Delete => "DELETE", + } + } + + pub fn as_commit_message(&self) -> &str { + match *self { + StoreAction::Create => "Create", + StoreAction::Retrieve => "Retrieve", + StoreAction::Update => "Update", + StoreAction::Delete => "Delete", + } + } +} + +impl Display for StoreAction { + + fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { + write!(fmt, "StoreAction: {}", + match *self { + StoreAction::Create => "create", + StoreAction::Retrieve => "retrieve", + StoreAction::Update => "update", + StoreAction::Delete => "delete", + }) + } + +} + diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs new file mode 100644 index 00000000..c68743d3 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -0,0 +1,197 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 toml::Value; + +use libimagerror::into::IntoError; +use libimagstore::storeid::StoreId; + +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::result::Result; + +use vcs::git::action::StoreAction; + +use git2::Repository; + +/// Check the configuration whether we should commit interactively +pub fn commit_interactive(config: &Value, action: &StoreAction) -> bool { + match config.lookup("commit.interactive") { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, 'store.hooks.stdhook_git_{}.commit.interactive' must be a Boolean.", + action); + warn!("Defaulting to commit.interactive = false"); + false + } + None => { + warn!("Unavailable configuration for"); + warn!("\t'store.hooks.stdhook_git_{}.commit.interactive'", action); + warn!("Defaulting to false"); + false + } + } +} + +/// Check the configuration whether we should commit with the editor +fn commit_with_editor(config: &Value, action: &StoreAction) -> bool { + match config.lookup("commit.interactive_editor") { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, 'store.hooks.stdhook_git_{}.commit.interactive_editor' must be a Boolean.", + action); + warn!("Defaulting to commit.interactive_editor = false"); + false + } + None => { + warn!("Unavailable configuration for"); + warn!("\t'store.hooks.stdhook_git_{}.commit.interactive_editor'", action); + warn!("Defaulting to false"); + false + } + } +} + +/// Get the commit default message +fn commit_default_msg<'a>(config: &'a Value, action: &'a StoreAction) -> &'a str { + match config.lookup("commit.message") { + Some(&Value::String(ref b)) => b, + Some(_) => { + warn!("Configuration error, 'store.hooks.stdhook_git_{}.commit.message' must be a String.", + action); + warn!("Defaulting to commit.message = '{}'", action.as_commit_message()); + action.as_commit_message() + } + None => { + warn!("Unavailable configuration for"); + warn!("\t'store.hooks.stdhook_git_{}.commit.message'", action); + warn!("Defaulting to commit.message = '{}'", action.as_commit_message()); + action.as_commit_message() + } + } +} + +/// Get the commit template +/// +/// TODO: Implement good template string +fn commit_template(action: &StoreAction, id: &StoreId) -> String { + format!(r#" +# Please commit your changes and remove these lines. +# +# You're about to commit changes via the {action} Hook +# +# Altered file: {id} +# + "#, + action = action, + id = id.local().display()) +} + +/// Generate a commit message +/// +/// Uses the functions `commit_interactive()` and `commit_with_editor()` +/// or reads one from the commandline or uses the `commit_default_msg()` string to create a commit +/// message. +pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction, id: &StoreId) -> Result { + use libimaginteraction::ask::ask_string; + use libimagutil::edit::edit_in_tmpfile_with_command; + use std::process::Command; + + if commit_interactive(config, &action) { + if commit_with_editor(config, &action) { + repo.config() + .map_err_into(GHEK::GitConfigFetchError) + .and_then(|c| c.get_string("core.editor").map_err_into(GHEK::GitConfigEditorFetchError)) + .map_err_into(GHEK::ConfigError) + .map(Command::new) + .and_then(|cmd| { + let mut s = commit_template(&action, id); + edit_in_tmpfile_with_command(cmd, &mut s).map(|_| s) + .map_err_into(GHEK::EditorError) + }) + } else { + Ok(ask_string("Commit Message", None, false, false, None, "> ")) + } + } else { + Ok(String::from(commit_default_msg(config, &action))) + } +} + +/// Check whether the hook should abort if the repository cannot be initialized +pub fn abort_on_repo_init_err(cfg: &Value) -> bool { + get_bool_cfg(Some(cfg), "abort_on_repo_init_failure", true, true) +} + +/// Get the branch which must be checked out before running the hook (if any). +/// +/// If there is no configuration for this, this is `Ok(None)`, otherwise we try to find the +/// configuration `String`. +pub fn ensure_branch(cfg: Option<&Value>) -> Result> { + match cfg { + Some(cfg) => { + match cfg.lookup("ensure_branch") { + Some(&Value::String(ref s)) => Ok(Some(s.clone())), + Some(_) => { + warn!("Configuration error, 'ensure_branch' must be a String."); + Err(GHEK::ConfigTypeError.into_error()) + .map_err_into(GHEK::ConfigTypeError) + }, + None => { + debug!("No key `ensure_branch'"); + Ok(None) + }, + } + }, + None => Ok(None), + } +} + +/// Check whether we should check out a branch before committing. +pub fn do_checkout_ensure_branch(cfg: Option<&Value>) -> bool { + get_bool_cfg(cfg, "try_checkout_ensure_branch", true, true) +} + +/// Helper to get a boolean value from the configuration. +fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool) -> bool { + cfg.map(|cfg| { + match cfg.lookup(name) { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, '{}' must be a Boolean (true|false).", name); + warn!("Assuming '{}' now.", on_fail); + on_fail + }, + None => { + warn!("No key '{}' - Assuming '{}'", name, on_unavail); + on_unavail + }, + } + }) + .unwrap_or_else(|| { + warn!("No configuration to fetch {} from, assuming {}", name, on_unavail); + on_unavail + }) +} + +/// Check whether the hook is enabled or not. If the config is not there, the hook is _enabled_ by +/// default. +pub fn is_enabled(cfg: &Value) -> bool { + get_bool_cfg(Some(cfg), "enabled", true, true) +} + diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs new file mode 100644 index 00000000..a2756a55 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -0,0 +1,236 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; +use std::path::Path; +use std::fmt::{Debug, Formatter, Error as FmtError}; +use std::result::Result as RResult; + +use toml::Value; + +use libimagerror::trace::trace_error; +use libimagstore::storeid::StoreId; +use libimagstore::hook::Hook; +use libimagstore::hook::result::HookResult; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::accessor::StoreIdAccessor; +use libimagutil::debug_result::*; + +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::runtime::Runtime as GRuntime; + +pub struct DeleteHook { + storepath: PathBuf, + + runtime: GRuntime, + + position: HookPosition, +} + +impl DeleteHook { + + pub fn new(storepath: PathBuf, p: HookPosition) -> DeleteHook { + DeleteHook { + runtime: GRuntime::new(&storepath), + storepath: storepath, + position: p, + } + } + +} + +impl Debug for DeleteHook { + fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { + write!(fmt, "DeleteHook(storepath={:?}, repository={}, pos={:?}, cfg={:?})", + self.storepath, + (if self.runtime.has_repository() { "Some(_)" } else { "None" }), + self.position, + self.runtime.has_config()) + } +} + + +impl Hook for DeleteHook { + + fn name(&self) -> &'static str { + "stdhook_git_delete" + } + + /// Set the configuration of the hook. See + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()`. + /// + /// This function traces the error (using `trace_error()`) that + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()` + /// returns, if any. + fn set_config(&mut self, config: &Value) { + if let Err(e) = self.runtime.set_config(config) { + trace_error(&e); + } + } + +} + +impl HookDataAccessorProvider for DeleteHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for DeleteHook { + + fn access(&self, id: &StoreId) -> HookResult<()> { + use libimagerror::into::IntoError; + use vcs::git::action::StoreAction; + use vcs::git::config::commit_message; + use vcs::git::error::MapIntoHookError; + use vcs::git::util::fetch_index; + use vcs::git::config::abort_on_repo_init_err; + use vcs::git::config::is_enabled; + use git2::{ADD_DEFAULT, STATUS_WT_DELETED, IndexMatchedPath}; + + debug!("[GIT DELETE HOOK]: {:?}", id); + + let action = StoreAction::Delete; + let cfg = try!(self.runtime.config_value_or_err(&action)); + + if !is_enabled(cfg) { + return Ok(()) + } + + if !self.runtime.has_repository() { + debug!("[GIT DELETE HOOK]: Runtime has no repository..."); + if try!(self.runtime.config_value_or_err(&action).map(|c| abort_on_repo_init_err(c))) { + // Abort on repo init failure + debug!("[GIT DELETE HOOK]: Config says we should abort if we have no repository"); + debug!("[GIT DELETE HOOK]: Returing Err(_)"); + return Err(GHEK::RepositoryInitError.into_error()) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + } else { + debug!("[GIT DELETE HOOK]: Config says it is okay to not have a repository"); + debug!("[GIT DELETE HOOK]: Returing Ok(())"); + return Ok(()) + } + } + + let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); + let repo = try!(self.runtime.repository(&action)); + let mut index = try!(fetch_index(repo, &action)); + + let signature = try!( + repo.signature() + .map_err_into(GHEK::MkSignature) + .map_dbg_err_str("Failed to fetch signature") + .map_dbg_str("[GIT DELETE HOOK]: Fetched signature object") + .map_into_hook_error() + ); + + let head = try!( + repo.head() + .map_err_into(GHEK::HeadFetchError) + .map_dbg_err_str("Failed to fetch HEAD") + .map_dbg_str("[GIT DELETE HOOK]: Fetched HEAD") + .map_into_hook_error() + ); + + let file_status = try!( + repo + .status_file(id.local()) + .map_dbg_err_str("Failed to fetch file status") + .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_dbg_str("[GIT DELETE HOOK]: Fetched file status") + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() + ); + + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { + debug!("[GIT DELETE HOOK]: Checking file status for: {}", path.display()); + if file_status.contains(STATUS_WT_DELETED) { + debug!("[GIT DELETE HOOK]: File is deleted: {}", path.display()); + 0 + } else { + debug!("[GIT DELETE HOOK]: Ignoring file: {}", path.display()); + 1 + } + }; + + try!( + index.add_all(&[id.local()], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) + .map_err_into(GHEK::RepositoryPathAddingError) + .map_dbg_err_str("Failed to add to index") + .map_dbg_str("[GIT DELETE HOOK]: Fetched index") + .map_into_hook_error() + ); + + let tree_id = try!( + index.write_tree() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_dbg_str("[GIT DELETE HOOK]: Wrote index tree") + .map_into_hook_error() + ); + + let mut parents = Vec::new(); + { + let commit = try!( + repo.find_commit(head.target().unwrap()) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find commit HEAD") + .map_dbg_str("[GIT DELETE HOOK]: Found commit HEAD") + .map_into_hook_error() + ); + parents.push(commit); + } + + // for converting from Vec to Vec<&Commit> + let parents = parents.iter().collect::>(); + + let tree = try!( + repo.find_tree(tree_id) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find tree") + .map_dbg_str("[GIT DELETE HOOK]: Found tree for index") + .map_into_hook_error() + ); + + let message = try!(commit_message(&repo, cfg, action, &id) + .map_dbg_err_str("Failed to get commit message") + .map_dbg_str("[GIT DELETE HOOK]: Got commit message")); + + try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + .map_dbg_str("Committed") + .map_dbg_err_str("Failed to commit") + .map_dbg_str("[GIT DELETE HOOK]: Committed") + .map_err_into(GHEK::RepositoryCommittingError) + .map_into_hook_error() + ); + + index.write() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_dbg_str("[GIT DELETE HOOK]: Wrote index") + .map_into_hook_error() + .map(|_| ()) + } + +} + diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs new file mode 100644 index 00000000..0481ebef --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -0,0 +1,96 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 git2::Error as Git2Error; + +use libimagstore::hook::error::HookError as HE; +use libimagstore::hook::error::HookErrorKind as HEK; +use libimagstore::hook::result::HookResult; + +generate_error_module!( + generate_error_types!(GitHookError, GitHookErrorKind, + ConfigError => "Configuration Error", + NoConfigError => "No Configuration", + ConfigTypeError => "Configuration value type wrong", + + RepositoryError => "Error while interacting with git repository", + RepositoryInitError => "Error while loading the git repository", + RepositoryBackendError => "Error in the git library", + RepositoryBranchError => "Error while interacting with git branch(es)", + RepositoryBranchNameFetchingError => "Error while fetching branch name", + RepositoryWrongBranchError => "Error because repository is on wrong branch", + RepositoryIndexFetchingError => "Error while fetching Repository Index", + RepositoryIndexWritingError => "Error while writing Repository Index", + RepositoryPathAddingError => "Error while adding Path to Index", + RepositoryCommittingError => "Error while committing", + RepositoryParentFetchingError => "Error while fetching parent of commit", + + HeadFetchError => "Error while getting HEAD", + NotOnBranch => "No Branch is checked out", + MkRepo => "Repository creation error", + MkSignature => "Error while building Signature object", + + RepositoryFileStatusError => "Error while getting file status", + + GitConfigFetchError => "Error fetching git config", + GitConfigEditorFetchError => "Error fetching 'editor' from git config", + EditorError => "Error while calling editor" + ); +); + +impl GitHookError { + + pub fn inside_of(self, h: HEK) -> HookResult { + Err(HE::new(h, Some(Box::new(self)))) + } + +} + +impl From for HE { + + fn from(he: GitHookError) -> HE { + HE::new(HEK::HookExecutionError, Some(Box::new(he))) + } + +} + +impl From for GitHookError { + + fn from(ge: Git2Error) -> GitHookError { + GitHookError::new(GitHookErrorKind::RepositoryBackendError, Some(Box::new(ge))) + } + +} + +pub trait MapIntoHookError { + fn map_into_hook_error(self) -> Result; +} + +impl MapIntoHookError for Result { + + fn map_into_hook_error(self) -> Result { + self.map_err(|e| HE::new(HEK::HookExecutionError, Some(Box::new(e)))) + } + +} + +pub use self::error::GitHookError; +pub use self::error::GitHookErrorKind; +pub use self::error::MapErrInto; + diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs new file mode 100644 index 00000000..1f126247 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -0,0 +1,28 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + +mod action; +mod config; +pub mod delete; +mod error; +mod result; +mod runtime; +pub mod update; +pub mod util; + diff --git a/libimagstorestdhook/src/vcs/git/result.rs b/libimagstorestdhook/src/vcs/git/result.rs new file mode 100644 index 00000000..bf161eb5 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/result.rs @@ -0,0 +1,24 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::result::Result as RResult; + +use vcs::git::error::GitHookError; + +pub type Result = RResult; diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs new file mode 100644 index 00000000..27fde40c --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -0,0 +1,178 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; + +use git2::Repository; +use toml::Value; + +use libimagerror::into::IntoError; +use libimagerror::trace::MapErrTrace; +use libimagstore::hook::error::CustomData; +use libimagstore::hook::error::HookErrorKind as HEK; +use libimagstore::hook::result::HookResult; +use libimagutil::debug_result::*; + +use vcs::git::action::StoreAction; +use vcs::git::result::Result; +use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; + +/// Runtime object for git hook implementations. +/// +/// Contains some utility functionality to hold the repository and the configuration for the hooks. +pub struct Runtime { + repository: Option, + config: Option, +} + +impl Runtime { + + /// Build a `Runtime` object, pass the store path to build the `Repository` instance the + /// `Runtime` has to contain. + /// + /// If the building of the `Repository` fails, this function `trace_error()`s the error and + /// returns a `Runtime` object that does _not_ contain a `Repository`. + pub fn new(storepath: &PathBuf) -> Runtime { + Runtime { + repository: Repository::open(storepath).map_err_trace().ok(), + config: None, + } + } + + /// Set the configuration for the `Runtime`. Always returns `Ok(())`. + pub fn set_config(&mut self, cfg: &Value) -> Result<()> { + self.config = Some(cfg.clone()); + Ok(()) + } + + /// Check whether the `Runtime` has a `Repository` + pub fn has_repository(&self) -> bool { + self.repository.is_some() + } + + /// Check whether the `Runtime` has a configuration + pub fn has_config(&self) -> bool { + self.config.is_some() + } + + /// Get the the config value by reference or get an `Err()` which can be returned to the callee + /// of the Hook. + /// + /// The `action` Argument is required in case of `Err()` so the error message can be build + /// correctly. + pub fn config_value_or_err(&self, action: &StoreAction) -> HookResult<&Value> { + self.config + .as_ref() + .ok_or(GHEK::NoConfigError.into_error()) + .map_err_into(GHEK::ConfigError) + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) + .map_err(|e| e.with_custom_data(CustomData::default().aborting(false))) + .map_dbg_err(|_| { + format!("[GIT {} HOOK]: Couldn't get Value object from config", action.uppercase()) + }) + } + + /// Get the `Repository` object from the `Runtime` or an `Err()` that can be returned to the + /// callee of the Hook. + /// + /// The `action` Argument is required in case of `Err()` so the error message can be build + /// correctly. + pub fn repository(&self, action: &StoreAction) -> HookResult<&Repository> { + use vcs::git::error::MapIntoHookError; + + debug!("[GIT {} HOOK]: Getting repository", action.uppercase()); + self.repository + .as_ref() + .ok_or(GHEK::MkRepo.into_error()) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Repository", action.uppercase())) + .map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase())) + } + + /// Ensure that the branch that is put in the configuration file is checked out, if any. + pub fn ensure_cfg_branch_is_checked_out(&self, action: &StoreAction) -> HookResult<()> { + use vcs::git::config::ensure_branch; + use vcs::git::config::do_checkout_ensure_branch; + + debug!("[GIT {} HOOK]: Ensuring branch checkout", action.uppercase()); + let head = try!(self + .repository(action) + .and_then(|r| { + debug!("[GIT {} HOOK]: Repository fetched, getting head", action.uppercase()); + r.head() + .map_dbg_err_str("Couldn't fetch HEAD") + .map_dbg_err(|e| format!("\tbecause = {:?}", e)) + .map_err_into(GHEK::HeadFetchError) + .map_err(|e| e.into()) + })); + debug!("[GIT {} HOOK]: HEAD fetched", action.uppercase()); + + // TODO: Fail if not on branch? hmmh... I'm not sure + if !head.is_branch() { + debug!("[GIT {} HOOK]: HEAD is not a branch", action.uppercase()); + return Err(GHEK::NotOnBranch.into_error().into()); + } + debug!("[GIT {} HOOK]: HEAD is a branch", action.uppercase()); + + // Check out appropriate branch ... or fail + match ensure_branch(self.config.as_ref()) { + Ok(Some(s)) => { + debug!("[GIT {} HOOK]: We have to ensure branch: {}", action.uppercase(), s); + match head.name().map(|name| { + debug!("[GIT {} HOOK]: {} == {}", action.uppercase(), name, s); + name == s + }) { + Some(b) => { + if b { + debug!("[GIT {} HOOK]: Branch already checked out.", action.uppercase()); + Ok(()) + } else { + debug!("[GIT {} HOOK]: Branch not checked out.", action.uppercase()); + + if !do_checkout_ensure_branch(self.config.as_ref()) { + Err(GHEK::RepositoryWrongBranchError.into_error()) + .map_err_into(GHEK::RepositoryError) + } else { + // Else try to check out the branch... + unimplemented!() + } + } + }, + + None => Err(GHEK::RepositoryBranchNameFetchingError.into_error()) + .map_err_into(GHEK::RepositoryBranchError) + .map_err_into(GHEK::RepositoryError), + } + }, + Ok(None) => { + debug!("[GIT {} HOOK]: No branch to checkout", action.uppercase()); + Ok(()) + }, + + Err(e) => Err(e).map_err_into(GHEK::RepositoryError), + } + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) + .map_dbg(|_| format!("[GIT {} HOOK]: Branch checked out", action.uppercase())) + } + +} + diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs new file mode 100644 index 00000000..d84ffcff --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -0,0 +1,257 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::path::PathBuf; +use std::path::Path; +use std::fmt::{Debug, Formatter, Error as FmtError}; +use std::result::Result as RResult; + +use toml::Value; + +use libimagerror::trace::trace_error; +use libimagstore::hook::Hook; +use libimagstore::hook::accessor::StoreIdAccessor; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::result::HookResult; +use libimagstore::storeid::StoreId; +use libimagutil::debug_result::*; + +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::runtime::Runtime as GRuntime; + +/// The `UpdateHook` type +/// +/// Represents a hook which is executed whenever a entry in the store is updated (written to disk). +/// +/// # Time of execution +/// +/// This hook is executed _after_ the store operation succeeded, so _after_ the file is written to +/// disk. +pub struct UpdateHook { + storepath: PathBuf, + + runtime: GRuntime, + + position: HookPosition, +} + +impl UpdateHook { + + pub fn new(storepath: PathBuf, p: HookPosition) -> UpdateHook { + UpdateHook { + runtime: GRuntime::new(&storepath), + storepath: storepath, + position: p, + } + } + +} + +impl Debug for UpdateHook { + fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { + write!(fmt, "UpdateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?})", + self.storepath, + (if self.runtime.has_repository() { "Some(_)" } else { "None" }), + self.position, + self.runtime.has_config()) + } +} + +impl Hook for UpdateHook { + + fn name(&self) -> &'static str { + "stdhook_git_update" + } + + /// Set the configuration of the hook. See + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()`. + /// + /// This function traces the error (using `trace_error()`) that + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()` + /// returns, if any. + fn set_config(&mut self, config: &Value) { + if let Err(e) = self.runtime.set_config(config) { + trace_error(&e); + } + } + +} + +impl HookDataAccessorProvider for UpdateHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for UpdateHook { + + /// The implementation of the UpdateHook + /// + /// # Scope + /// + /// This hook takes the git index and commits it either interactively or with a default message, + /// if there is no configuration for an interactive commit. + /// + fn access(&self, id: &StoreId) -> HookResult<()> { + use libimagerror::into::IntoError; + use vcs::git::action::StoreAction; + use vcs::git::config::commit_message; + use vcs::git::error::MapIntoHookError; + use vcs::git::util::fetch_index; + use vcs::git::config::abort_on_repo_init_err; + use vcs::git::config::is_enabled; + use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; + + debug!("[GIT UPDATE HOOK]: {:?}", id); + + let action = StoreAction::Update; + let cfg = try!(self.runtime.config_value_or_err(&action)); + + if !is_enabled(cfg) { + return Ok(()); + } + + if !self.runtime.has_repository() { + debug!("[GIT UPDATE HOOK]: Runtime has no repository..."); + if try!(self.runtime.config_value_or_err(&action).map(|c| abort_on_repo_init_err(c))) { + // Abort on repo init failure + debug!("[GIT UPDATE HOOK]: Config says we should abort if we have no repository"); + debug!("[GIT UPDATE HOOK]: Returing Err(_)"); + return Err(GHEK::RepositoryInitError.into_error()) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + } else { + debug!("[GIT UPDATE HOOK]: Config says it is okay to not have a repository"); + debug!("[GIT UPDATE HOOK]: Returing Ok(())"); + return Ok(()) + } + } + + let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); + let repo = try!(self.runtime.repository(&action)); + + let file_status = try!( + repo + .status_file(id.local()) + .map_dbg_err_str("Failed to fetch file status") + .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_dbg_str("[GIT UPDATE HOOK]: Fetched file status") + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() + ); + + debug!("File status: STATUS_WT_NEW = {}", file_status.contains(STATUS_WT_NEW)); + debug!("File status: STATUS_WT_MODIFIED = {}", file_status.contains(STATUS_WT_MODIFIED)); + + if !file_status.contains(STATUS_WT_NEW) && !file_status.contains(STATUS_WT_MODIFIED) { + // File seems to be unmodified and not new. This means that the file is already + // committed and we can return here. + return Ok(()) + } + + let mut index = try!(fetch_index(repo, &action)); + + let signature = try!( + repo.signature() + .map_err_into(GHEK::MkSignature) + .map_dbg_err_str("Failed to fetch signature") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched signature object") + .map_into_hook_error() + ); + + let head = try!( + repo.head() + .map_err_into(GHEK::HeadFetchError) + .map_dbg_err_str("Failed to fetch HEAD") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched HEAD") + .map_into_hook_error() + ); + + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { + if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) { + debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display()); + 0 + } else { + debug!("[GIT CREATE HOOK]: Ignoring file: {}", path.display()); + 1 + } + }; + + try!( + index.add_all(&[id.local()], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) + .map_err_into(GHEK::RepositoryPathAddingError) + .map_dbg_err_str("Failed to add to index") + .map_dbg(|_| format!("[GIT UPDATE HOOK]: Added id ({:?}) to index", id)) + .map_into_hook_error() + ); + + let tree_id = try!( + index.write_tree() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_dbg_str("[GIT UPDATE HOOK]: Wrote tree") + .map_into_hook_error() + ); + + let mut parents = Vec::new(); + { + let commit = try!( + repo.find_commit(head.target().unwrap()) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find commit HEAD") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched commit parents of HEAD") + .map_into_hook_error() + ); + parents.push(commit); + } + + // for converting from Vec to Vec<&Commit> + let parents = parents.iter().collect::>(); + + let tree = try!( + repo.find_tree(tree_id) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find tree") + .map_dbg_str("[GIT UPDATE HOOK]: Found Tree for parents") + .map_into_hook_error() + ); + + let message = try!(commit_message(&repo, cfg, StoreAction::Update, &id) + .map_dbg_err_str("Failed to get commit message") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched commit message")); + + try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + .map_dbg_str("Committed") + .map_dbg_err_str("Failed to commit") + .map_err_into(GHEK::RepositoryCommittingError) + .map_into_hook_error() + ); + + index.write() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_into_hook_error() + .map(|_| ()) + } + +} + diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs new file mode 100644 index 00000000..bfeb2c2f --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -0,0 +1,42 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + +//! Utility functionality for integrating git hooks in the store +//! +//! Contains primitives to create a repository within the store path + +use git2::{Repository, Index}; + +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::action::StoreAction; +use vcs::git::error::MapIntoHookError; + +use libimagutil::debug_result::*; +use libimagstore::hook::error::HookError; + +pub fn fetch_index(repo: &Repository, action: &StoreAction) -> Result { + debug!("[GIT {} HOOK]: Getting Index", action.uppercase()); + repo.index() + .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Index", action.uppercase())) + .map_dbg(|_| format!("[GIT {} HOOK]: Index object fetched", action.uppercase())) + .map_err_into(GHEK::RepositoryIndexFetchingError) + .map_into_hook_error() +} + diff --git a/libimagstorestdhook/src/vcs/mod.rs b/libimagstorestdhook/src/vcs/mod.rs new file mode 100644 index 00000000..7449c7bc --- /dev/null +++ b/libimagstorestdhook/src/vcs/mod.rs @@ -0,0 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + +pub mod git; diff --git a/libimagtimeui/src/cli.rs b/libimagtimeui/src/cli.rs index 001c2a45..7db6c33d 100644 --- a/libimagtimeui/src/cli.rs +++ b/libimagtimeui/src/cli.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 clap::Arg; pub fn build_datetime_cli_component<'a, 'b>() -> Arg<'a, 'b> { diff --git a/libimagtimeui/src/date.rs b/libimagtimeui/src/date.rs index 987ad764..e44cc389 100644 --- a/libimagtimeui/src/date.rs +++ b/libimagtimeui/src/date.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 chrono::naive::date::NaiveDate as ChronoNaiveDate; use parse::Parse; diff --git a/libimagtimeui/src/datetime.rs b/libimagtimeui/src/datetime.rs index b78a7436..be718794 100644 --- a/libimagtimeui/src/datetime.rs +++ b/libimagtimeui/src/datetime.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 chrono::naive::datetime::NaiveDateTime as ChronoNaiveDateTime; use parse::Parse; diff --git a/libimagtimeui/src/lib.rs b/libimagtimeui/src/lib.rs index fa47a930..df9c4e47 100644 --- a/libimagtimeui/src/lib.rs +++ b/libimagtimeui/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagtimeui/src/parse.rs b/libimagtimeui/src/parse.rs index 8898e184..b578551b 100644 --- a/libimagtimeui/src/parse.rs +++ b/libimagtimeui/src/parse.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub trait Parse : Sized { fn parse(s: &str) -> Option; diff --git a/libimagtimeui/src/time.rs b/libimagtimeui/src/time.rs index dc5cbc1a..3506a0be 100644 --- a/libimagtimeui/src/time.rs +++ b/libimagtimeui/src/time.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 chrono::naive::time::NaiveTime as ChronoNaiveTime; use parse::Parse; diff --git a/libimagtimeui/src/ui.rs b/libimagtimeui/src/ui.rs index 691e8c47..642d5203 100644 --- a/libimagtimeui/src/ui.rs +++ b/libimagtimeui/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + pub fn time_ui_fmtstr() -> &'static str { "YYYY-MM-DD[THH[:mm[:ss]]]" } diff --git a/libimagtodo/src/error.rs b/libimagtodo/src/error.rs index ebcebf3e..c19a6e52 100644 --- a/libimagtodo/src/error.rs +++ b/libimagtodo/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + generate_error_module!( generate_error_types!(TodoError, TodoErrorKind, ConversionError => "Conversion Error", diff --git a/libimagtodo/src/lib.rs b/libimagtodo/src/lib.rs index 171856f8..5a7584ec 100644 --- a/libimagtodo/src/lib.rs +++ b/libimagtodo/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagtodo/src/result.rs b/libimagtodo/src/result.rs index d14bf499..7962851c 100644 --- a/libimagtodo/src/result.rs +++ b/libimagtodo/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 error::TodoError; use std::result::Result as RResult; diff --git a/libimagtodo/src/task.rs b/libimagtodo/src/task.rs index 16ba3167..d51d0407 100644 --- a/libimagtodo/src/task.rs +++ b/libimagtodo/src/task.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::collections::BTreeMap; use std::ops::{Deref, DerefMut}; use std::io::BufRead; diff --git a/libimagutil/Cargo.toml b/libimagutil/Cargo.toml index 53e0e0ee..61dd88e7 100644 --- a/libimagutil/Cargo.toml +++ b/libimagutil/Cargo.toml @@ -4,7 +4,10 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] +url = "1.1" +boolinator = "2.4.0" lazy_static = "0.1.15" log = "0.3" regex = "0.1" +tempfile = "2.1.1" diff --git a/libimagutil/src/cli_validators.rs b/libimagutil/src/cli_validators.rs new file mode 100644 index 00000000..068d5834 --- /dev/null +++ b/libimagutil/src/cli_validators.rs @@ -0,0 +1,39 @@ +//! Functions to be used for clap::Arg::validator() +//! to validate arguments + +use std::path::PathBuf; +use boolinator::Boolinator; + +pub fn is_existing_path(s: String) -> Result<(), String> { + PathBuf::from(s.clone()).exists().as_result((), format!("Not a File or Directory: {}", s)) +} + +pub fn is_file(s: String) -> Result<(), String> { + PathBuf::from(s.clone()).is_file().as_result((), format!("Not a File: {}", s)) +} + +pub fn is_directory(s: String) -> Result<(), String> { + PathBuf::from(s.clone()).is_dir().as_result((), format!("Not a Directory: {}", s)) +} + +pub fn is_integer(s: String) -> Result<(), String> { + use std::str::FromStr; + + let i : Result = FromStr::from_str(&s); + i.map(|_| ()).map_err(|_| format!("Not an integer: {}", s)) +} + +pub fn is_url(s: String) -> Result<(), String> { + use url::Url; + Url::parse(&s).map(|_| ()).map_err(|_| format!("Not a URL: {}", s)) +} + +pub fn is_tag(s: String) -> Result<(), String> { + use regex::Regex; + lazy_static! { static ref TAG_RE : Regex = Regex::new("[:alpha:][:word:]*").unwrap(); } + + TAG_RE + .is_match(&s) + .as_result((), format!("Not a valid Tag: '{}' - Valid is [a-zA-Z][0-9a-zA-Z]*", s)) +} + diff --git a/libimagutil/src/debug_result.rs b/libimagutil/src/debug_result.rs index 405cddd8..e7506633 100644 --- a/libimagutil/src/debug_result.rs +++ b/libimagutil/src/debug_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + // Generates a extension for the `Result`, named `DebugResult` which has functionality to // print either `T` or `E` via `debug!()`. generate_result_logging_extension!( diff --git a/libimagutil/src/edit.rs b/libimagutil/src/edit.rs new file mode 100644 index 00000000..3cf459f4 --- /dev/null +++ b/libimagutil/src/edit.rs @@ -0,0 +1,55 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 std::io::Read; +use std::io::Seek; +use std::io::SeekFrom; +use std::io::Write; +use std::process::Command; +use std::io::Error as IOError; + +use tempfile::NamedTempFile; + +pub fn edit_in_tmpfile_with_command(mut cmd: Command, s: &mut String) -> Result { + let file = try!(NamedTempFile::new()); + let file_path = file.path(); + let mut file = try!(file.reopen()); + + try!(file.write_all(&s.clone().into_bytes()[..])); + try!(file.sync_data()); + + cmd.arg(file_path) + .status() + .and_then(|status| { + if status.success() { + file.sync_data() + .and_then(|_| file.seek(SeekFrom::Start(0))) + .and_then(|_| { + let mut new_s = String::new(); + let res = file.read_to_string(&mut new_s); + *s = new_s; + res + }) + .map(|_| true) + } else { + Ok(false) + } + }) +} + diff --git a/libimagutil/src/info_result.rs b/libimagutil/src/info_result.rs index 235f4f53..9c106bc8 100644 --- a/libimagutil/src/info_result.rs +++ b/libimagutil/src/info_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + // Generates a extension for the `Result`, named `DebugResult` which has functionality to // print either `T` or `E` via `info!()`. generate_result_logging_extension!( diff --git a/libimagutil/src/ismatch.rs b/libimagutil/src/ismatch.rs index 9739f139..e47ee6bf 100644 --- a/libimagutil/src/ismatch.rs +++ b/libimagutil/src/ismatch.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #[macro_export] macro_rules! is_match { ($expression: expr, $($pattern:tt)+) => { diff --git a/libimagutil/src/iter.rs b/libimagutil/src/iter.rs index 52d723bf..2f2bb5b7 100644 --- a/libimagutil/src/iter.rs +++ b/libimagutil/src/iter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + /// Folds its contents to a result. pub trait FoldResult: Sized { type Item; diff --git a/libimagutil/src/key_value_split.rs b/libimagutil/src/key_value_split.rs index f1a7a7c7..ff2870bf 100644 --- a/libimagutil/src/key_value_split.rs +++ b/libimagutil/src/key_value_split.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 regex::Regex; use std::convert::Into; diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index 16183e7b..dc7876ad 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + #![deny( non_camel_case_types, non_snake_case, @@ -16,9 +35,14 @@ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate regex; +extern crate url; +extern crate boolinator; +extern crate tempfile; #[macro_use] mod log_result; +pub mod cli_validators; pub mod debug_result; +pub mod edit; pub mod info_result; pub mod ismatch; pub mod iter; diff --git a/libimagutil/src/log_result.rs b/libimagutil/src/log_result.rs index 95da299b..45977b2a 100644 --- a/libimagutil/src/log_result.rs +++ b/libimagutil/src/log_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + /// This macro is used to generate extensions for the `Result` type which only have /// sideeffects. /// diff --git a/libimagutil/src/variants.rs b/libimagutil/src/variants.rs index a57e694d..2f0746d2 100644 --- a/libimagutil/src/variants.rs +++ b/libimagutil/src/variants.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + /** * Generate variants of a base value by applying parts * diff --git a/libimagutil/src/warn_exit.rs b/libimagutil/src/warn_exit.rs index 399ebcd8..fbda4d25 100644 --- a/libimagutil/src/warn_exit.rs +++ b/libimagutil/src/warn_exit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + /// This function prints the string `s` via the `warn!()` macro and then exits with the code `code` /// as status. /// diff --git a/libimagutil/src/warn_result.rs b/libimagutil/src/warn_result.rs index b30e71f8..6b05b285 100644 --- a/libimagutil/src/warn_result.rs +++ b/libimagutil/src/warn_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 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 +// + // Generates a extension for the `Result`, named `DebugResult` which has functionality to // print either `T` or `E` via `warn!()`. generate_result_logging_extension!( diff --git a/tests/utils.sh b/tests/utils.sh index 6480337d..57c5b079 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -47,10 +47,16 @@ cat_entry() { } reset_store() { + rm -rf "${STORE}"/.git rm -r "${STORE}" } call_test() { + prepare_store_directory || { + err "Preparing store directory failed" + exit 1 + } + out "-- TESTING: '$1' --" $1 result=$? @@ -63,6 +69,27 @@ call_test() { success "-- SUCCESS: '$1' --" } +__git() { + out "Calling git: $*" + git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git $* +} + +__git_commit() { + out "Calling git-commit: $*" + git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git commit -m "$*" +} + +prepare_store_directory() { + out "Preparing /tmp/store" + mkdir -p /tmp/store/ &&\ + touch /tmp/store/.gitkeep &&\ + __git init &&\ + __git config --local user.email "imag@imag-pim.org" &&\ + __git config --local user.name "Imag CI" &&\ + __git add .gitkeep &&\ + __git_commit 'Initial commit: .gitkeep' +} + invoke_tests() { out "Invoking tests." if [[ ! -z "$INVOKE_TEST" ]]; then