1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// This is free and unencumbered software released into the public domain.
use crate::BoxError;
use asimov_module::ModuleName;
use clientele::{StandardOptions, crates::clap::Subcommand};
use std::string::String;
#[derive(Debug, Subcommand)]
pub enum PackageCommand {
/// Initialize `.asimov/module.yaml`.
Init {
/// The name of the module
name: Option<String>,
},
/// Check the package directory for missing files/directories.
Check {},
/// Display the package directory tree.
Tree {},
/// Scaffold a new module
#[cfg(feature = "package-scaffold")]
Scaffold {
/// The module's short name, e.g. `widget` for `asimov-widget-module`
name: ModuleName,
/// The target directory to create the module in.
/// Defaults to `./asimov-<name>-module`.
#[arg(long)]
dir: Option<String>,
/// Scaffold a program of this kind, e.g. `fetcher` for
/// `asimov-widget-fetcher`. May be repeated to scaffold several
/// programs at once.
#[arg(long, default_value = "emitter")]
program: Vec<String>,
/// A short summary of what this module does.
/// Defaults to a summary derived from the module's name.
#[arg(long)]
summary: Option<String>,
},
}
impl PackageCommand {
pub async fn run(&self, flags: &StandardOptions) -> Result<(), BoxError> {
use PackageCommand::*;
match self {
Init { name } => init(name, flags).await,
Check {} => check(flags).await,
Tree {} => tree(flags).await,
#[cfg(feature = "package-scaffold")]
Scaffold {
name,
dir,
program,
summary,
} => new(name, dir.as_deref(), program, summary.as_deref(), flags).await,
}
}
}
mod check;
pub use check::*;
mod init;
pub use init::*;
mod tree;
pub use tree::*;
#[cfg(feature = "package-scaffold")]
mod scaffold;
#[cfg(feature = "package-scaffold")]
pub use scaffold::*;