mod/gitignore: add nix

This commit is contained in:
Dmitriy Pleshevskiy 2024-04-03 23:47:36 +03:00
parent 1eb140cbcc
commit bba79b915b
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
3 changed files with 11 additions and 0 deletions

View file

@ -13,6 +13,8 @@ pub struct GitIgnoreModuleCliArgs {
#[clap(long)] #[clap(long)]
pub nodejs: bool, pub nodejs: bool,
#[clap(long)] #[clap(long)]
pub nix: bool,
#[clap(long)]
pub custom: Option<String>, pub custom: Option<String>,
} }
@ -24,6 +26,7 @@ impl From<GitIgnoreModuleCliArgs> for GitIgnoreModuleArgs {
direnv: args.direnv, direnv: args.direnv,
rust: args.rust, rust: args.rust,
nodejs: args.nodejs, nodejs: args.nodejs,
nix: args.nix,
custom: args.custom, custom: args.custom,
} }
} }

View file

@ -7,6 +7,7 @@ pub struct GitIgnoreModuleConfig {
pub direnv: Option<bool>, pub direnv: Option<bool>,
pub rust: Option<bool>, pub rust: Option<bool>,
pub nodejs: Option<bool>, pub nodejs: Option<bool>,
pub nix: Option<bool>,
pub custom: Option<String>, pub custom: Option<String>,
} }
@ -18,6 +19,7 @@ impl From<GitIgnoreModuleConfig> for GitIgnoreModuleArgs {
direnv: cfg.direnv.unwrap_or_default(), direnv: cfg.direnv.unwrap_or_default(),
rust: cfg.rust.unwrap_or_default(), rust: cfg.rust.unwrap_or_default(),
nodejs: cfg.nodejs.unwrap_or_default(), nodejs: cfg.nodejs.unwrap_or_default(),
nix: cfg.nix.unwrap_or_default(),
custom: cfg.custom, custom: cfg.custom,
} }
} }

View file

@ -22,6 +22,10 @@ const RUST_PART: &str = "\
# rust # rust
/target"; /target";
const NIX_PART: &str = "\
# nix
/result";
const NODEJS_PART: &str = "\ const NODEJS_PART: &str = "\
# nodejs # nodejs
node_modules/"; node_modules/";
@ -32,6 +36,7 @@ pub struct GitIgnoreModuleArgs {
pub direnv: bool, pub direnv: bool,
pub rust: bool, pub rust: bool,
pub nodejs: bool, pub nodejs: bool,
pub nix: bool,
pub custom: Option<String>, pub custom: Option<String>,
} }
@ -42,6 +47,7 @@ fn make_gitignore_content(args: GitIgnoreModuleArgs) -> String {
args.direnv.then_some(DIRENV_PART), args.direnv.then_some(DIRENV_PART),
args.rust.then_some(RUST_PART), args.rust.then_some(RUST_PART),
args.nodejs.then_some(NODEJS_PART), args.nodejs.then_some(NODEJS_PART),
args.nix.then_some(NIX_PART),
args.custom.map(|c| format!("# custom\n{}", c)).as_deref(), args.custom.map(|c| format!("# custom\n{}", c)).as_deref(),
] ]
.iter() .iter()