cli: rename cook command to make
This commit is contained in:
parent
9a491acf37
commit
285ed30c58
4 changed files with 17 additions and 17 deletions
28
src/cli.rs
28
src/cli.rs
|
@ -19,7 +19,7 @@ mod direnv;
|
|||
mod gitignore;
|
||||
|
||||
#[derive(Debug, Clone, clap::Args)]
|
||||
struct CookCommand {
|
||||
struct MakeCommand {
|
||||
modules: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
|
@ -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<String, String>,
|
||||
make_files: HashMap<String, String>,
|
||||
force: bool,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
|||
let config = read_config(¤t_dir)?;
|
||||
|
||||
match args.command {
|
||||
Command::Cook(_cook_args) => {
|
||||
let mut cook_files: HashMap<String, String> = HashMap::new();
|
||||
Command::Make(_make_args) => {
|
||||
let mut make_files: HashMap<String, String> = 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<String, String> = HashMap::new();
|
||||
let mut make_files: HashMap<String, String> = 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,5 +6,5 @@ pub mod gitignore;
|
|||
pub trait Module {
|
||||
type ModuleArgs;
|
||||
|
||||
fn cook(&self, args: Self::ModuleArgs) -> HashMap<String, String>;
|
||||
fn make(&self, args: Self::ModuleArgs) -> HashMap<String, String>;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct DirenvModule;
|
|||
impl Module for DirenvModule {
|
||||
type ModuleArgs = DirenvModuleArgs;
|
||||
|
||||
fn cook(&self, args: Self::ModuleArgs) -> HashMap<String, String> {
|
||||
fn make(&self, args: Self::ModuleArgs) -> HashMap<String, String> {
|
||||
HashMap::from([(String::from(".envrc"), make_gitignore_content(args))])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ pub struct GitIgnoreModule;
|
|||
impl Module for GitIgnoreModule {
|
||||
type ModuleArgs = GitIgnoreModuleArgs;
|
||||
|
||||
fn cook(&self, args: Self::ModuleArgs) -> HashMap<String, String> {
|
||||
fn make(&self, args: Self::ModuleArgs) -> HashMap<String, String> {
|
||||
HashMap::from([(String::from(".gitignore"), make_gitignore_content(args))])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue