diff options
Diffstat (limited to 'bin')
| -rw-r--r-- | bin/src/config.rs | 5 | ||||
| -rw-r--r-- | bin/src/lib.rs | 1 | ||||
| -rw-r--r-- | bin/src/list.rs | 14 | ||||
| -rw-r--r-- | bin/src/main.rs | 6 |
4 files changed, 24 insertions, 2 deletions
diff --git a/bin/src/config.rs b/bin/src/config.rs index 29b6c9e..0f09618 100644 --- a/bin/src/config.rs +++ b/bin/src/config.rs | |||
| @@ -31,6 +31,8 @@ pub enum SubCommand { | |||
| 31 | Explain(Explain), | 31 | Explain(Explain), |
| 32 | /// Dump a sample config to stdout | 32 | /// Dump a sample config to stdout |
| 33 | Dump(Dump), | 33 | Dump(Dump), |
| 34 | /// List all available lints | ||
| 35 | List(List), | ||
| 34 | } | 36 | } |
| 35 | 37 | ||
| 36 | #[derive(Parser, Debug)] | 38 | #[derive(Parser, Debug)] |
| @@ -205,6 +207,9 @@ pub struct Explain { | |||
| 205 | #[derive(Parser, Debug)] | 207 | #[derive(Parser, Debug)] |
| 206 | pub struct Dump {} | 208 | pub struct Dump {} |
| 207 | 209 | ||
| 210 | #[derive(Parser, Debug)] | ||
| 211 | pub struct List {} | ||
| 212 | |||
| 208 | #[derive(Debug, Copy, Clone)] | 213 | #[derive(Debug, Copy, Clone)] |
| 209 | pub enum OutFormat { | 214 | pub enum OutFormat { |
| 210 | #[cfg(feature = "json")] | 215 | #[cfg(feature = "json")] |
diff --git a/bin/src/lib.rs b/bin/src/lib.rs index 8200347..e814667 100644 --- a/bin/src/lib.rs +++ b/bin/src/lib.rs | |||
| @@ -5,6 +5,7 @@ pub mod err; | |||
| 5 | pub mod explain; | 5 | pub mod explain; |
| 6 | pub mod fix; | 6 | pub mod fix; |
| 7 | pub mod lint; | 7 | pub mod lint; |
| 8 | pub mod list; | ||
| 8 | pub mod session; | 9 | pub mod session; |
| 9 | pub mod traits; | 10 | pub mod traits; |
| 10 | 11 | ||
diff --git a/bin/src/list.rs b/bin/src/list.rs new file mode 100644 index 0000000..4fe3039 --- /dev/null +++ b/bin/src/list.rs | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | pub mod main { | ||
| 2 | use crate::err::StatixErr; | ||
| 3 | |||
| 4 | use lib::LINTS; | ||
| 5 | |||
| 6 | pub fn main() -> Result<(), StatixErr> { | ||
| 7 | let mut lints = (&*LINTS).clone(); | ||
| 8 | lints.as_mut_slice().sort_by(|a, b| a.code().cmp(&b.code())); | ||
| 9 | for l in lints { | ||
| 10 | println!("W{:02} {}", l.code(), l.name()); | ||
| 11 | } | ||
| 12 | Ok(()) | ||
| 13 | } | ||
| 14 | } | ||
diff --git a/bin/src/main.rs b/bin/src/main.rs index be79bb8..ebd230e 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | use clap::Parser; | 1 | use clap::Parser; |
| 2 | |||
| 3 | #[rustfmt::skip] | ||
| 2 | use statix::{ | 4 | use statix::{ |
| 3 | config::{Opts, SubCommand}, | 5 | config::{Opts, SubCommand}, |
| 4 | dump, | ||
| 5 | err::StatixErr, | 6 | err::StatixErr, |
| 6 | explain, fix, lint, | 7 | lint, fix, explain, dump, list, |
| 7 | }; | 8 | }; |
| 8 | 9 | ||
| 9 | fn _main() -> Result<(), StatixErr> { | 10 | fn _main() -> Result<(), StatixErr> { |
| @@ -14,6 +15,7 @@ fn _main() -> Result<(), StatixErr> { | |||
| 14 | SubCommand::Single(config) => fix::main::single(config), | 15 | SubCommand::Single(config) => fix::main::single(config), |
| 15 | SubCommand::Explain(config) => explain::main::main(config), | 16 | SubCommand::Explain(config) => explain::main::main(config), |
| 16 | SubCommand::Dump(_) => dump::main::main(), | 17 | SubCommand::Dump(_) => dump::main::main(), |
| 18 | SubCommand::List(_) => list::main::main(), | ||
| 17 | } | 19 | } |
| 18 | } | 20 | } |
| 19 | 21 | ||
