-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_cli.rs
More file actions
56 lines (49 loc) · 1.47 KB
/
custom_cli.rs
File metadata and controls
56 lines (49 loc) · 1.47 KB
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
//! Example: Custom CLI with individual linters
//!
//! This example shows how to create a custom CLI that uses individual
//! linter functions from the torrust-linting package.
use anyhow::Result;
use clap::{Parser, Subcommand};
use torrust_linting::{
run_clippy_linter, run_markdown_linter, run_rustfmt_linter, run_shellcheck_linter, run_toml_linter, run_yaml_linter,
};
#[derive(Parser)]
#[command(name = "custom-linter")]
#[command(about = "A custom linter CLI using torrust-linting")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
/// Lint only Rust code (clippy + rustfmt)
Rust,
/// Lint only markup files (markdown + yaml + toml)
Markup,
/// Lint only shell scripts
Shell,
}
fn main() -> Result<()> {
// Initialize logging (you can customize this)
torrust_linting::init_tracing();
let cli = Cli::parse();
match cli.command {
Commands::Rust => {
println!("🦀 Running Rust linters...");
run_clippy_linter()?;
run_rustfmt_linter()?;
}
Commands::Markup => {
println!("📄 Running markup linters...");
run_markdown_linter()?;
run_yaml_linter()?;
run_toml_linter()?;
}
Commands::Shell => {
println!("🐚 Running shell script linter...");
run_shellcheck_linter()?;
}
}
println!("✅ All selected linters passed!");
Ok(())
}