|
1 | 1 | use crate::arg::ModuleArgs;
|
2 | 2 | use crate::settings::{ModuleSettings, PkgUnit};
|
3 |
| -use anyhow::{bail, Context as _, Result}; |
| 3 | +use anyhow::{Context as _, Result, bail}; |
4 | 4 | use core::fmt;
|
5 | 5 | use indexmap::IndexMap;
|
6 | 6 | use quote::{format_ident, quote};
|
@@ -29,13 +29,14 @@ static SUB_MOD_NAME: &str = "m";
|
29 | 29 | ///
|
30 | 30 | /// * `CliError` - If the command line arguments are invalid.
|
31 | 31 | /// * `IoError` - If the configuration file is not found or cannot be read.
|
32 |
| -#[expect(clippy::single_call_fn, reason = "better readability")] |
33 | 32 | pub fn module(args: ModuleArgs) -> Result<()> {
|
34 | 33 | let args = ModuleSettings::resolve(args);
|
35 | 34 | let ans_modu_names = match (args.module_name, args.module_name_regex) {
|
36 | 35 | (Some(modu_name), None) => {
|
37 |
| - vec![AnsibleModuleName::new(&modu_name) |
38 |
| - .with_context(|| format!("failed to parse module name: {modu_name}"))?] |
| 36 | + vec![ |
| 37 | + AnsibleModuleName::new(&modu_name) |
| 38 | + .with_context(|| format!("failed to parse module name: {modu_name}"))?, |
| 39 | + ] |
39 | 40 | }
|
40 | 41 | (None, Some(regex)) => match_module_name(®ex)?,
|
41 | 42 | (None, None) => match_module_name("*")?,
|
@@ -310,8 +311,8 @@ fn create_cargo_toml(pkg_name: &str, pkg_dir: &Path) -> Result<()> {
|
310 | 311 | [package]
|
311 | 312 | name = "sample"
|
312 | 313 | version = "0.1.0"
|
313 |
| - edition = "2021" |
314 |
| - rust-version = "1.83" |
| 314 | + edition.workspace = true |
| 315 | + rust-version.workspace = true |
315 | 316 | "#,
|
316 | 317 | )?;
|
317 | 318 | if let Some(package) = manifest.package.as_mut() {
|
@@ -521,21 +522,21 @@ type AnsModuleJson = IndexMap<String, AnsModuleItem>;
|
521 | 522 |
|
522 | 523 | #[derive(Debug, Clone, Serialize, Deserialize)]
|
523 | 524 | /// module field
|
524 |
| -pub struct AnsModuleItem { |
| 525 | +struct AnsModuleItem { |
525 | 526 | /// 'doc' field
|
526 | 527 | pub doc: AnsModuleDoc,
|
527 | 528 | }
|
528 | 529 |
|
529 | 530 | #[derive(Debug, Clone, Serialize, Deserialize)]
|
530 | 531 | /// doc field
|
531 |
| -pub struct AnsModuleDoc { |
| 532 | +struct AnsModuleDoc { |
532 | 533 | /// 'options' field
|
533 | 534 | pub options: Option<IndexMap<String, AnsModuleDocOption>>,
|
534 | 535 | }
|
535 | 536 |
|
536 | 537 | #[derive(Debug, Clone, Serialize, Deserialize)]
|
537 | 538 | /// doc option field
|
538 |
| -pub struct AnsModuleDocOption { |
| 539 | +struct AnsModuleDocOption { |
539 | 540 | // TODO: add description field
|
540 | 541 | // #[serde(default)]
|
541 | 542 | // pub description: Vec<String>,
|
|
0 commit comments