Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 98addf4d54 | |||
| 2bc5e3c712 | |||
| 2c1972141b | |||
| 0e37f99cd2 | |||
| d9ad91c55d | |||
| 44916a91db | |||
| ce4fd8ccc9 | |||
| 640e9507a1 |
7 changed files with 29 additions and 978 deletions
966
Cargo.lock
generated
966
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -13,8 +13,6 @@ anode = { path = "./anode" }
|
||||||
anode-macros-input = { path = "./anode-macros-input" }
|
anode-macros-input = { path = "./anode-macros-input" }
|
||||||
anode-macros = { path = "./anode-macros" }
|
anode-macros = { path = "./anode-macros" }
|
||||||
anode-build = { path = "./anode-build" }
|
anode-build = { path = "./anode-build" }
|
||||||
# git
|
|
||||||
forgejo-openapi = { git = "https://git.dzuchun.ing/dzu/forgejo-openapi.git", default-features = false }
|
|
||||||
# crates.io
|
# crates.io
|
||||||
syn = { version = "2", default-features = false }
|
syn = { version = "2", default-features = false }
|
||||||
quote = { version = "1", 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 syn::{File, punctuated::Punctuated};
|
||||||
|
|
||||||
use anode_macros_input::pretty_span;
|
use anode_macros_input::pretty_span;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
runs:
|
using: composite
|
||||||
using: composite
|
steps:
|
||||||
steps:
|
- run: ${{ forgejo.action_path }}/main
|
||||||
- run: ${{ forgejo.action_path }}/main
|
shell: bash
|
||||||
shell: bash
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ fn try_get(action: &Action) -> ItemFn {
|
||||||
|
|
||||||
let input_lit = LitStr::new(name, proc_macro2::Span::call_site());
|
let input_lit = LitStr::new(name, proc_macro2::Span::call_site());
|
||||||
let input_envvar = LitStr::new(
|
let input_envvar = LitStr::new(
|
||||||
&format!("INPUT_{}", name.to_uppercase().replace('-', "_")),
|
&format!("INPUT_{}", name.to_uppercase()),
|
||||||
proc_macro2::Span::call_site(),
|
proc_macro2::Span::call_site(),
|
||||||
);
|
);
|
||||||
let mut envvar: syn::Expr = syn::parse_quote!( ::std::env::var_os(#input_envvar) );
|
let mut envvar: syn::Expr = syn::parse_quote!( ::std::env::var_os(#input_envvar) );
|
||||||
|
|
@ -66,7 +66,7 @@ fn try_get(action: &Action) -> ItemFn {
|
||||||
envvar = syn::parse_quote!( #envvar.or_else(|| Some(::std::ffi::OsString::from(String::from(#def)))) );
|
envvar = syn::parse_quote!( #envvar.or_else(|| Some(::std::ffi::OsString::from(String::from(#def)))) );
|
||||||
}
|
}
|
||||||
let mut parse_input: syn::ExprIf = syn::parse_quote! {
|
let mut parse_input: syn::ExprIf = syn::parse_quote! {
|
||||||
if let Some(envvar) = #envvar {
|
if let Some(envvar) = #envvar && !envvar.is_empty() {
|
||||||
match #parser(envvar) {
|
match #parser(envvar) {
|
||||||
Ok(ok) => #input_ident = Some(ok),
|
Ok(ok) => #input_ident = Some(ok),
|
||||||
Err(error) => #errors.push((#input_lit, ::anode::InputErrorMessage::Parsing(::std::boxed::Box::new(error)))),
|
Err(error) => #errors.push((#input_lit, ::anode::InputErrorMessage::Parsing(::std::boxed::Box::new(error)))),
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,3 @@ edition = "2024"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anode-macros.workspace = true
|
anode-macros.workspace = true
|
||||||
thiserror.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> {
|
pub fn PathBuf(input: OsString) -> Result<PathBuf, core::convert::Infallible> {
|
||||||
Ok(input.into())
|
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 {
|
pub mod parse {
|
||||||
|
|
@ -89,9 +107,6 @@ pub mod parse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "forge-forgejo")]
|
|
||||||
pub use forgejo_openapi as forgejo;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InputError(#[doc(hidden)] pub Box<[(&'static str, InputErrorMessage)]>);
|
pub struct InputError(#[doc(hidden)] pub Box<[(&'static str, InputErrorMessage)]>);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue