mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Improve admin command reference generation
- Change xtasks to use `clap` for argument parsing - Generate admin command reference manually instead of with `clap_markdown` - Split admin command reference into multiple files
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
type TaskResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! tasks {
|
||||
(
|
||||
$(
|
||||
$module:ident: $desc:literal
|
||||
),*
|
||||
) => {
|
||||
$(pub(super) mod $module;)*
|
||||
|
||||
#[derive(clap::Subcommand)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub(super) enum Task {
|
||||
$(
|
||||
#[clap(about = $desc, long_about = None)]
|
||||
$module($module::Args),
|
||||
)*
|
||||
}
|
||||
|
||||
impl Task {
|
||||
pub(super) fn invoke(self, common_args: $crate::Args) -> TaskResult<impl std::process::Termination> {
|
||||
match self {
|
||||
$(
|
||||
Self::$module(task_args) => {
|
||||
$module::run(common_args, task_args)
|
||||
},
|
||||
)*
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
tasks! {
|
||||
generate_docs: "Generate various documentation files. This is run automatically when compiling the website."
|
||||
}
|
||||
Reference in New Issue
Block a user