Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d9ad91c55d | |||
| 44916a91db | |||
| ce4fd8ccc9 |
4 changed files with 19 additions and 6 deletions
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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" ]
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue