mod/gitignore: add editors

This commit is contained in:
Dmitriy Pleshevskiy 2024-03-19 11:48:10 +03:00
parent 285ed30c58
commit 154c9de515
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
3 changed files with 13 additions and 0 deletions

View file

@ -2,6 +2,8 @@ use crate::module::gitignore::GitIgnoreModuleArgs;
#[derive(Debug, Clone, clap::Args)] #[derive(Debug, Clone, clap::Args)]
pub struct GitIgnoreModuleCliArgs { pub struct GitIgnoreModuleCliArgs {
#[clap(long)]
pub editors: bool,
#[clap(long)] #[clap(long)]
pub env: bool, pub env: bool,
#[clap(long)] #[clap(long)]
@ -17,6 +19,7 @@ pub struct GitIgnoreModuleCliArgs {
impl From<GitIgnoreModuleCliArgs> for GitIgnoreModuleArgs { impl From<GitIgnoreModuleCliArgs> for GitIgnoreModuleArgs {
fn from(args: GitIgnoreModuleCliArgs) -> Self { fn from(args: GitIgnoreModuleCliArgs) -> Self {
GitIgnoreModuleArgs { GitIgnoreModuleArgs {
editors: args.editors,
env: args.env, env: args.env,
direnv: args.direnv, direnv: args.direnv,
rust: args.rust, rust: args.rust,

View file

@ -2,6 +2,7 @@ use crate::module::gitignore::GitIgnoreModuleArgs;
#[derive(Default, serde::Deserialize, serde::Serialize)] #[derive(Default, serde::Deserialize, serde::Serialize)]
pub struct GitIgnoreModuleConfig { pub struct GitIgnoreModuleConfig {
pub editors: Option<bool>,
pub env: Option<bool>, pub env: Option<bool>,
pub direnv: Option<bool>, pub direnv: Option<bool>,
pub rust: Option<bool>, pub rust: Option<bool>,
@ -12,6 +13,7 @@ pub struct GitIgnoreModuleConfig {
impl From<GitIgnoreModuleConfig> for GitIgnoreModuleArgs { impl From<GitIgnoreModuleConfig> for GitIgnoreModuleArgs {
fn from(cfg: GitIgnoreModuleConfig) -> Self { fn from(cfg: GitIgnoreModuleConfig) -> Self {
GitIgnoreModuleArgs { GitIgnoreModuleArgs {
editors: cfg.editors.unwrap_or_default(),
env: cfg.env.unwrap_or_default(), env: cfg.env.unwrap_or_default(),
direnv: cfg.direnv.unwrap_or_default(), direnv: cfg.direnv.unwrap_or_default(),
rust: cfg.rust.unwrap_or_default(), rust: cfg.rust.unwrap_or_default(),

View file

@ -2,6 +2,12 @@ use std::collections::HashMap;
use super::Module; use super::Module;
const EDITORS_PART: &str = "\
# editors
.idea/
.vscode/
*.swp";
const ENV_PART: &str = "\ const ENV_PART: &str = "\
# env # env
.env* .env*
@ -21,6 +27,7 @@ const NODEJS_PART: &str = "\
node_modules/"; node_modules/";
pub struct GitIgnoreModuleArgs { pub struct GitIgnoreModuleArgs {
pub editors: bool,
pub env: bool, pub env: bool,
pub direnv: bool, pub direnv: bool,
pub rust: bool, pub rust: bool,
@ -30,6 +37,7 @@ pub struct GitIgnoreModuleArgs {
fn make_gitignore_content(args: GitIgnoreModuleArgs) -> String { fn make_gitignore_content(args: GitIgnoreModuleArgs) -> String {
[ [
args.editors.then_some(EDITORS_PART),
args.env.then_some(ENV_PART), args.env.then_some(ENV_PART),
args.direnv.then_some(DIRENV_PART), args.direnv.then_some(DIRENV_PART),
args.rust.then_some(RUST_PART), args.rust.then_some(RUST_PART),