diff --git a/src/cli.rs b/src/cli.rs index 24a494d..e3c547c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -19,7 +19,7 @@ mod direnv; mod gitignore; #[derive(Debug, Clone, clap::Args)] -struct CookCommand { +struct MakeCommand { modules: Option>, } @@ -41,7 +41,7 @@ struct AddCommand { #[derive(Debug, Clone, clap::Subcommand)] #[clap(propagate_version = true)] enum Command { - Cook(CookCommand), + Make(MakeCommand), Add { #[clap(short, long)] force: bool, @@ -83,12 +83,12 @@ fn tui_question(question: &str, default: bool) -> bool { value } -fn cook( +fn make( current_dir: PathBuf, - cook_files: HashMap, + make_files: HashMap, force: bool, ) -> Result<(), Box> { - for (file_name, file_content) in cook_files { + for (file_name, file_content) in make_files { let file_path = ¤t_dir.join(file_name); let file_exists = file_path.exists(); let is_empty_file_content = file_content.trim().is_empty(); @@ -139,31 +139,31 @@ pub fn run() -> Result<(), Box> { let config = read_config(¤t_dir)?; match args.command { - Command::Cook(_cook_args) => { - let mut cook_files: HashMap = HashMap::new(); + Command::Make(_make_args) => { + let mut make_files: HashMap = HashMap::new(); if let Some(cfg) = config.direnv { - cook_files.extend(DirenvModule.cook(cfg.into())) + make_files.extend(DirenvModule.make(cfg.into())) } if let Some(cfg) = config.gitignore { - cook_files.extend(GitIgnoreModule.cook(cfg.into())); + make_files.extend(GitIgnoreModule.make(cfg.into())); } - cook(current_dir, cook_files, true) + make(current_dir, make_files, true) } Command::Add { force, command } => { - let mut cook_files: HashMap = HashMap::new(); + let mut make_files: HashMap = HashMap::new(); match command { - AddModuleCommand::Direnv(args) => cook_files.extend(DirenvModule.cook(args.into())), + AddModuleCommand::Direnv(args) => make_files.extend(DirenvModule.make(args.into())), AddModuleCommand::GitIgnore(args) => { - cook_files.extend(GitIgnoreModule.cook(args.into())) + make_files.extend(GitIgnoreModule.make(args.into())) } AddModuleCommand::External(_) => { unimplemented!("external commands") } }; - cook(current_dir, cook_files, force) + make(current_dir, make_files, force) } } } diff --git a/src/module.rs b/src/module.rs index 2209e4a..a43d974 100644 --- a/src/module.rs +++ b/src/module.rs @@ -6,5 +6,5 @@ pub mod gitignore; pub trait Module { type ModuleArgs; - fn cook(&self, args: Self::ModuleArgs) -> HashMap; + fn make(&self, args: Self::ModuleArgs) -> HashMap; } diff --git a/src/module/direnv.rs b/src/module/direnv.rs index 1ae8e4c..4d11fbd 100644 --- a/src/module/direnv.rs +++ b/src/module/direnv.rs @@ -33,7 +33,7 @@ pub struct DirenvModule; impl Module for DirenvModule { type ModuleArgs = DirenvModuleArgs; - fn cook(&self, args: Self::ModuleArgs) -> HashMap { + fn make(&self, args: Self::ModuleArgs) -> HashMap { HashMap::from([(String::from(".envrc"), make_gitignore_content(args))]) } } diff --git a/src/module/gitignore.rs b/src/module/gitignore.rs index a92187d..0c9868d 100644 --- a/src/module/gitignore.rs +++ b/src/module/gitignore.rs @@ -49,7 +49,7 @@ pub struct GitIgnoreModule; impl Module for GitIgnoreModule { type ModuleArgs = GitIgnoreModuleArgs; - fn cook(&self, args: Self::ModuleArgs) -> HashMap { + fn make(&self, args: Self::ModuleArgs) -> HashMap { HashMap::from([(String::from(".gitignore"), make_gitignore_content(args))]) } }