From: "Georgy Yakovlev" <gyakovlev@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/cargo-ebuild:master commit in: src/
Date: Wed, 25 Aug 2021 15:35:05 +0000 (UTC) [thread overview]
Message-ID: <1629904288.fe6608425e6217097aab82b89d4a72b79d94c8da.gyakovlev@gentoo> (raw)
commit: fe6608425e6217097aab82b89d4a72b79d94c8da
Author: Luca Barbato <lu_zero <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 29 14:24:27 2021 +0000
Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Wed Aug 25 15:11:28 2021 +0000
URL: https://gitweb.gentoo.org/proj/cargo-ebuild.git/commit/?id=fe660842
Add an option to provide a custom tera template
Signed-off-by: Luca Barbato <lu_zero <AT> gentoo.org>
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
src/lib.rs | 12 ++++++++++--
src/main.rs | 5 ++++-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index 2ecb1f3..8f53e17 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -123,7 +123,11 @@ pub fn gen_ebuild_data(manifest_path: Option<PathBuf>) -> Result<EbuildConfig> {
Ok(EbuildConfig::from_package(root_pkg, crates, licenses))
}
-pub fn write_ebuild(ebuild_data: EbuildConfig, ebuild_path: impl AsRef<Path>) -> Result<()> {
+pub fn write_ebuild(
+ ebuild_data: EbuildConfig,
+ ebuild_path: impl AsRef<Path>,
+ template_path: Option<impl AsRef<Path>>,
+) -> Result<()> {
// Open the file where we'll write the ebuild
let mut file = OpenOptions::new()
.write(true)
@@ -137,7 +141,11 @@ pub fn write_ebuild(ebuild_data: EbuildConfig, ebuild_path: impl AsRef<Path>) ->
let mut tera = tera::Tera::default();
let mut context = tera::Context::from_serialize(ebuild_data)?;
- tera.add_raw_template("ebuild.tera", include_str!("ebuild.tera"))?;
+ if let Some(template) = template_path {
+ tera.add_template_file(template, Some("ebuild.tera"))?;
+ } else {
+ tera.add_raw_template("ebuild.tera", include_str!("ebuild.tera"))?;
+ }
context.insert("cargo_ebuild_ver", env!("CARGO_PKG_VERSION"));
context.insert("this_year", &time::OffsetDateTime::now_utc().year());
diff --git a/src/main.rs b/src/main.rs
index 94aa1af..fe8881c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,6 +22,9 @@ struct Args {
#[structopt(name = "PATH", long = "manifest-path", parse(from_os_str))]
/// Path to Cargo.toml.
manifest_path: Option<PathBuf>,
+ #[structopt(name = "TEMPLATE", long = "template-path", short)]
+ /// Non-standard template
+ template_path: Option<PathBuf>,
}
#[derive(StructOpt, Debug)]
@@ -46,7 +49,7 @@ fn main() -> Result<()> {
let ebuild_path = format!("{}-{}.ebuild", ebuild_data.name, ebuild_data.version);
- write_ebuild(ebuild_data, &ebuild_path)?;
+ write_ebuild(ebuild_data, &ebuild_path, opt.template_path.as_ref())?;
println!("Wrote: {}", ebuild_path);
next reply other threads:[~2021-08-25 15:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-25 15:35 Georgy Yakovlev [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-01-04 20:23 [gentoo-commits] proj/cargo-ebuild:master commit in: src/ Georgy Yakovlev
2023-01-04 19:51 Georgy Yakovlev
2023-01-04 19:51 Georgy Yakovlev
2021-10-07 19:03 Georgy Yakovlev
2021-08-26 7:51 Georgy Yakovlev
2021-08-25 15:35 Georgy Yakovlev
2021-08-25 15:35 Georgy Yakovlev
2021-08-03 4:58 Georgy Yakovlev
2021-08-02 6:57 Georgy Yakovlev
2021-06-19 22:34 Georgy Yakovlev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1629904288.fe6608425e6217097aab82b89d4a72b79d94c8da.gyakovlev@gentoo \
--to=gyakovlev@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox