exec.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // imag - the personal information management suite for the commandline
  3. // Copyright (C) 2015, 2016 Matthias Beyer <mail@beyermatthias.de> and contributors
  4. //
  5. // This library is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU Lesser General Public
  7. // License as published by the Free Software Foundation; version
  8. // 2.1 of the License.
  9. //
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. // Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public
  16. // License along with this library; if not, write to the Free Software
  17. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. //
  19. use clap::ArgMatches;
  20. use libimagstore::store::FileLockEntry;
  21. use result::Result;
  22. use tagable::*;
  23. use ui::{get_add_tags, get_remove_tags};
  24. pub fn exec_cli_for_entry(matches: &ArgMatches, entry: &mut FileLockEntry) -> Result<()> {
  25. if let Some(ts) = get_add_tags(matches) {
  26. for t in ts {
  27. if let Err(e) = entry.add_tag(t) {
  28. return Err(e);
  29. }
  30. }
  31. }
  32. if let Some(ts) = get_remove_tags(matches) {
  33. for t in ts {
  34. if let Err(e) = entry.remove_tag(t) {
  35. return Err(e);
  36. }
  37. }
  38. }
  39. Ok(())
  40. }