diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 2d36099e..8547ce2a 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -52,3 +52,7 @@ updates:
directory: "/crates/leon"
schedule:
interval: "daily"
+ - package-ecosystem: "cargo"
+ directory: "/crates/leon-macros"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml
index 899fb7ae..5d949d64 100644
--- a/.github/workflows/release-pr.yml
+++ b/.github/workflows/release-pr.yml
@@ -17,6 +17,7 @@ on:
- fs-lock
- normalize-path
- leon
+ - leon-macros
version:
description: Version to release
required: true
diff --git a/Cargo.lock b/Cargo.lock
index 0dd1b4b7..72e75d9e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -231,6 +231,7 @@ dependencies = [
"itertools",
"jobslot",
"leon",
+ "leon-macros",
"maybe-owned",
"miette",
"normalize-path",
@@ -1338,6 +1339,16 @@ dependencies = [
"tinytemplate",
]
+[[package]]
+name = "leon-macros"
+version = "0.0.0"
+dependencies = [
+ "leon",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.15",
+]
+
[[package]]
name = "libc"
version = "0.2.141"
diff --git a/Cargo.toml b/Cargo.toml
index c4fd9e9c..e9cfe47a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ members = [
"crates/normalize-path",
"crates/detect-targets",
"crates/leon",
+ "crates/leon-macros",
]
[profile.release]
diff --git a/crates/bin/src/args.rs b/crates/bin/src/args.rs
index cedab272..cb914561 100644
--- a/crates/bin/src/args.rs
+++ b/crates/bin/src/args.rs
@@ -31,7 +31,7 @@ use strum_macros::EnumCount;
pub struct Args {
/// Packages to install.
///
- /// Syntax: crate[@version]
+ /// Syntax: `crate[@version]`
///
/// Each value is either a crate name alone, or a crate name followed by @ and the version to
/// install. The version syntax is as with the --version option.
diff --git a/crates/binstalk/Cargo.toml b/crates/binstalk/Cargo.toml
index 62fdacc7..ebaf997e 100644
--- a/crates/binstalk/Cargo.toml
+++ b/crates/binstalk/Cargo.toml
@@ -22,6 +22,7 @@ home = "0.5.4"
itertools = "0.10.5"
jobslot = { version = "0.2.11", features = ["tokio"] }
leon = { version = "1.0.0", path = "../leon" }
+leon-macros = { version = "0.0.0", path = "../leon-macros" }
maybe-owned = "0.3.4"
miette = "5.7.0"
normalize-path = { version = "0.2.0", path = "../normalize-path" }
diff --git a/crates/binstalk/src/fetchers/gh_crate_meta/hosting.rs b/crates/binstalk/src/fetchers/gh_crate_meta/hosting.rs
index e6a7ed91..df26071c 100644
--- a/crates/binstalk/src/fetchers/gh_crate_meta/hosting.rs
+++ b/crates/binstalk/src/fetchers/gh_crate_meta/hosting.rs
@@ -1,5 +1,6 @@
use itertools::Itertools;
-use leon::{template, Item, Template};
+use leon::{Item, Template};
+use leon_macros::template;
use url::Url;
use crate::errors::BinstallError;
@@ -16,62 +17,36 @@ pub enum RepositoryHost {
/// Make sure to update possible_dirs in `bins::infer_bin_dir_template`
/// if you modified FULL_FILENAMES or NOVERSION_FILENAMES.
pub const FULL_FILENAMES: &[Template<'_>] = &[
- template!("/", { "name" }, "-", { "target" }, "-v", { "version" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "-", { "target" }, "-", { "version" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "-", { "version" }, "-", { "target" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "-v", { "version" }, "-", { "target" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "_", { "target" }, "_v", { "version" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "_", { "target" }, "_", { "version" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "_", { "version" }, "_", { "target" }, {
- "archive-suffix"
- }),
- template!("/", { "name" }, "_v", { "version" }, "_", { "target" }, {
- "archive-suffix"
- }),
+ template!("/{ name }-{ target }-v{ version }{ archive-suffix }"),
+ template!("/{ name }-{ target }-{ version }{ archive-suffix }"),
+ template!("/{ name }-{ version }-{ target }{ archive-suffix }"),
+ template!("/{ name }-v{ version }-{ target }{ archive-suffix }"),
+ template!("/{ name }_{ target }_v{ version }{ archive-suffix }"),
+ template!("/{ name }_{ target }_{ version }{ archive-suffix }"),
+ template!("/{ name }_{ version }_{ target }{ archive-suffix }"),
+ template!("/{ name }_v{ version }_{ target }{ archive-suffix }"),
];
pub const NOVERSION_FILENAMES: &[Template<'_>] = &[
- template!("/", { "name" }, "-", { "target" }, { "archive-suffix" }),
- template!("/", { "name" }, "_", { "target" }, { "archive-suffix" }),
+ template!("/{ name }-{ target }{ archive-suffix }"),
+ template!("/{ name }_{ target }{ archive-suffix }"),
];
const GITHUB_RELEASE_PATHS: &[Template<'_>] = &[
- template!({ "repo" }, "/releases/download/", { "version" }),
- template!({ "repo" }, "/releases/download/v", { "version" }),
+ template!("{ repo }/releases/download/{ version }"),
+ template!("{ repo }/releases/download/v{ version }"),
];
const GITLAB_RELEASE_PATHS: &[Template<'_>] = &[
- template!(
- { "repo" },
- "/-/releases/",
- { "version" },
- "/downloads/binaries"
- ),
- template!(
- { "repo" },
- "/-/releases/v",
- { "version" },
- "/downloads/binaries"
- ),
+ template!("{ repo }/-/releases/{ version }/downloads/binaries"),
+ template!("{ repo }/-/releases/v{ version }/downloads/binaries"),
];
-const BITBUCKET_RELEASE_PATHS: &[Template<'_>] = &[template!({ "repo" }, "/downloads")];
+const BITBUCKET_RELEASE_PATHS: &[Template<'_>] = &[template!("{ repo }/downloads")];
const SOURCEFORGE_RELEASE_PATHS: &[Template<'_>] = &[
- template!({ "repo" }, "/files/binaries/", { "version" }),
- template!({ "repo" }, "/files/binaries/v", { "version" }),
+ template!("{ repo }/files/binaries/{ version }"),
+ template!("{ repo }/files/binaries/v{ version }"),
];
impl RepositoryHost {
diff --git a/crates/binstalk/src/helpers/futures_resolver.rs b/crates/binstalk/src/helpers/futures_resolver.rs
index 38b4eb98..0a550519 100644
--- a/crates/binstalk/src/helpers/futures_resolver.rs
+++ b/crates/binstalk/src/helpers/futures_resolver.rs
@@ -1,7 +1,7 @@
use std::{future::Future, pin::Pin};
use tokio::sync::mpsc;
-/// Given multiple futures with output = Result