diff options
author | Freya Murphy <freya@freyacat.org> | 2025-01-16 14:45:14 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-01-16 14:45:14 -0500 |
commit | 60985236c7070425c28aa0c5ce675306d06ab123 (patch) | |
tree | 7448aef5dadf19d4504151ebc370f9e20757ef10 /src/lib.rs | |
download | iris-60985236c7070425c28aa0c5ce675306d06ab123.tar.gz iris-60985236c7070425c28aa0c5ce675306d06ab123.tar.bz2 iris-60985236c7070425c28aa0c5ce675306d06ab123.zip |
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 52 |
1 files changed, 52 insertions, 0 deletions
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 <contact@freyacat.org> + +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 <http://www.gnu.org/licenses/>."; + +/// Opens file writer at `path` with copyright header already written +pub(crate) fn get_writer<P>(path: P, c: char) -> Result<BufWriter<File>> +where + P: AsRef<Path>, +{ + 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) +} |