From 60985236c7070425c28aa0c5ce675306d06ab123 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Thu, 16 Jan 2025 14:45:14 -0500 Subject: initial --- src/lib.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/lib.rs (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..27d4e6c --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,52 @@ +//! # Iris +//! A locking plugin manager for vim + +mod model; +pub use model::{config::Config, plugin::Plugin, repo::Repository}; + +mod parse; + +mod error; +pub use error::{Error, Result}; + +pub mod path; + +use std::{ + fs::File, + io::{BufWriter, Write}, + path::Path, +}; + +/// Iris copyright header prepended to all generated files +const COPYRIGHT_HEADER: &str = "\ +IRIS - A locking plugin manager for vim +Copyright © 2025 Freya Murphy + +This file is part of IRIS + +IRIS is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or (at +your option) any later version. + +IRIS 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with IRIS. If not, see ."; + +/// Opens file writer at `path` with copyright header already written +pub(crate) fn get_writer

(path: P, c: char) -> Result> +where + P: AsRef, +{ + let file = File::create(path)?; + let mut w = BufWriter::new(file); + for line in COPYRIGHT_HEADER.lines() { + writeln!(w, "{c}{c}{c} {line}")?; + } + writeln!(w)?; + Ok(w) +} -- cgit v1.2.3-freya