-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support configuration of toolbox - for now this is just enabling/disa…
…bling rules (#35) 1. Refactor the CLI parser into it's own file 2. Add support for basic configuration - toolbox.toml controls how the toolbox linter will behave 3. Add documentation to how config works 4. Added subcommand `genconfig` that prints out default config
- Loading branch information
1 parent
b97e4ef
commit f49d103
Showing
10 changed files
with
167 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Configuration for trunk toolbox. Generate default by calling 'trunk-toolbox genconfig' | ||
|
||
[ifchange] | ||
enabled = true | ||
|
||
[donotland] | ||
enabled = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// trunk-ignore-all(trunk-toolbox/do-not-land) | ||
use confique::toml::{self, FormatOptions}; | ||
use confique::Config; | ||
|
||
#[derive(Config)] | ||
pub struct Conf { | ||
#[config(nested)] | ||
pub ifchange: IfChangeConf, | ||
|
||
#[config(nested)] | ||
pub donotland: PlsNotLandConf, | ||
} | ||
|
||
impl Conf { | ||
pub fn print_default() { | ||
let default_config = toml::template::<Conf>(FormatOptions::default()); | ||
println!("{}", default_config); | ||
} | ||
} | ||
|
||
#[derive(Config)] | ||
pub struct IfChangeConf { | ||
#[config(default = true)] | ||
pub enabled: bool, | ||
} | ||
|
||
#[derive(Config)] | ||
pub struct PlsNotLandConf { | ||
#[config(default = true)] | ||
pub enabled: bool, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod config; | ||
pub mod diagnostic; | ||
pub mod git; | ||
pub mod rules; | ||
pub mod run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::config::Conf; | ||
use std::collections::HashSet; | ||
use std::path::PathBuf; | ||
|
||
use clap::{Parser, Subcommand}; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(version = env!("CARGO_PKG_VERSION"), author = "Trunk Technologies Inc.")] | ||
pub struct Cli { | ||
#[command(subcommand)] | ||
pub subcommand: Option<Subcommands>, | ||
|
||
pub files: Vec<String>, | ||
|
||
#[clap(long)] | ||
#[arg(default_value_t = String::from("HEAD"))] | ||
pub upstream: String, | ||
|
||
#[clap(long)] | ||
/// optional path to write results to | ||
pub results: Option<String>, | ||
} | ||
|
||
#[derive(Subcommand, Debug)] | ||
pub enum Subcommands { | ||
// print default config for toolbox | ||
/// Generate default configuration content for toolbox | ||
Genconfig, | ||
} | ||
|
||
pub struct Run { | ||
pub paths: HashSet<PathBuf>, | ||
pub config: Conf, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters