Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cbf119c424 | |||
| a69815f5df | |||
| 0f0c272046 | |||
| 2729d91fa5 | |||
| 0f301b15f5 | |||
| 7de555e13f | |||
| de29341b23 |
7 changed files with 978 additions and 29 deletions
970
Cargo.lock
generated
970
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using: composite
|
||||
steps:
|
||||
- run: ${{ forgejo.action_path }}/main
|
||||
shell: bash
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- run: ${{ forgejo.action_path }}/main
|
||||
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_envvar = LitStr::new(
|
||||
&format!("INPUT_{}", name.to_uppercase()),
|
||||
&format!("INPUT_{}", name.to_uppercase().replace('-', "_")),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
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)))) );
|
||||
}
|
||||
let mut parse_input: syn::ExprIf = syn::parse_quote! {
|
||||
if let Some(envvar) = #envvar && !envvar.is_empty() {
|
||||
if let Some(envvar) = #envvar {
|
||||
match #parser(envvar) {
|
||||
Ok(ok) => #input_ident = Some(ok),
|
||||
Err(error) => #errors.push((#input_lit, ::anode::InputErrorMessage::Parsing(::std::boxed::Box::new(error)))),
|
||||
|
|
|
|||
|
|
@ -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" ]
|
||||
|
|
|
|||
|
|
@ -70,24 +70,6 @@ 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 {
|
||||
|
|
@ -107,6 +89,9 @@ pub mod parse {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "forge-forgejo")]
|
||||
pub use forgejo_openapi as forgejo;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InputError(#[doc(hidden)] pub Box<[(&'static str, InputErrorMessage)]>);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue