Compare commits

..
Author SHA1 Message Date
dzu
d9ad91c55d add boolean parser 2026-02-13 14:08:06 +00:00
dzu
44916a91db remeve Forgejo-openapi from the workspace
There is literally to reason to mingle them
2026-02-13 10:17:50 +00:00
dzu
ce4fd8ccc9 add hard-coded paths warning 2026-02-13 10:16:18 +00:00
4 changed files with 19 additions and 6 deletions

View file

@ -13,8 +13,6 @@ 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 }

View file

@ -1,3 +1,4 @@
// 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;

View file

@ -6,7 +6,3 @@ edition = "2024"
[dependencies]
anode-macros.workspace = true
thiserror.workspace = true
forgejo-openapi = { workspace = true, optional = true }
[features]
forge-forgejo = [ "dep:forgejo-openapi" ]

View file

@ -70,6 +70,24 @@ pub mod __default_parser {
pub fn PathBuf(input: OsString) -> Result<PathBuf, core::convert::Infallible> {
Ok(input.into())
}
#[derive(Debug, thiserror::Error)]
#[error("Unknown boolean value: {}", _0.display())]
pub struct UnknownBoolean(OsString);
pub fn bool(input: OsString) -> Result<bool, UnknownBoolean> {
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 {