diff --git a/Cargo.toml b/Cargo.toml index 6d43f1a..cb2ce28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,8 @@ anode = { path = "./anode" } anode-macros-input = { path = "./anode-macros-input" } anode-macros = { path = "./anode-macros" } anode-build = { path = "./anode-build" } +# git +forgejo-openapi = { git = "https://git.dzuchun.ing/dzu/forgejo-openapi.git", default-features = false } # crates.io syn = { version = "2", default-features = false } quote = { version = "1", default-features = false } diff --git a/anode-build/src/lib.rs b/anode-build/src/lib.rs index e2d1f97..e91b6f1 100644 --- a/anode-build/src/lib.rs +++ b/anode-build/src/lib.rs @@ -1,4 +1,3 @@ -// WARN: be aware that both source code file path and output path and hard-coded. they might not work for you; if you have any suggestion for heuristics would determine these paths in a universal way, please let me know use syn::{File, punctuated::Punctuated}; use anode_macros_input::pretty_span; diff --git a/anode/Cargo.toml b/anode/Cargo.toml index ca29a33..3649d67 100644 --- a/anode/Cargo.toml +++ b/anode/Cargo.toml @@ -6,3 +6,7 @@ edition = "2024" [dependencies] anode-macros.workspace = true thiserror.workspace = true +forgejo-openapi = { workspace = true, optional = true } + +[features] +forge-forgejo = [ "dep:forgejo-openapi" ] diff --git a/anode/src/lib.rs b/anode/src/lib.rs index fa916d4..bda5cd6 100644 --- a/anode/src/lib.rs +++ b/anode/src/lib.rs @@ -70,24 +70,6 @@ pub mod __default_parser { pub fn PathBuf(input: OsString) -> Result { Ok(input.into()) } - - #[derive(Debug, thiserror::Error)] - #[error("Unknown boolean value: {}", _0.display())] - pub struct UnknownBoolean(OsString); - - pub fn bool(input: OsString) -> Result { - const VALID_TRUE: &[&[u8]] = &[b"TRUE", b"True", b"true", b"1"]; - const VALID_FALSE: &[&[u8]] = &[b"FALSE", b"False", b"false", b"0"]; - if VALID_TRUE.contains(&input.as_bytes()) { - return Ok(true); - } - - if VALID_FALSE.contains(&input.as_bytes()) { - return Ok(false); - } - - Err(UnknownBoolean(input)) - } } pub mod parse {