diff --git a/locales/en.toml b/locales/en.toml index 6537874..1a1b75b 100644 --- a/locales/en.toml +++ b/locales/en.toml @@ -10,13 +10,11 @@ how_to_get_started = "To get started: add dotfiles using `tuckr push` or add the running_prehook = "Running Prehook" running_posthook = "Running Posthook" symlinking_group = "Symlinking group" -dotfiles_will_be_converted = "The dotfiles at `%{location}` will be converted into Tuckr." dotfiles_created_at = "A dotfiles directory has been created at `%{location}`." groups_will_be_removed = "The following groups will be removed" x_available = "%{x} available" [warn] -want_to_convert_dotfiles = "Are you sure you want to convert your dotfiles to tuckr? (y/N)" want_to_override = "Do you want to override it? (y/N)" want_to_proceed = "Do you want to proceed? (y/N)" @@ -38,9 +36,6 @@ make_sure_dir_exists_or_run = "Make sure a `%{dir}` directory exists or run `%{c could_not_read_hooks = "Could not read Hooks, folder may not exist or does not have the appropriate permissions" failed_to_hook = "Failed to hook" got_invalid_group = "Got an invalid group: %{group}" -couldnt_create_required_dir = "Could not create required directory." -couldnt_open_curr_dir = "Could not open current directory" -couldnt_move_files = "Could not move files" no_dir_setup_for_x = "There's no directory set up for %{x}" no_x_setup_yet = "No %{x} have been setup yet" not_a_tuckr_dotfile = "`%{file}` is not a tuckr dotfile." diff --git a/locales/es-ES.toml b/locales/es-ES.toml index bf533cc..80c8a5b 100644 --- a/locales/es-ES.toml +++ b/locales/es-ES.toml @@ -10,13 +10,11 @@ how_to_get_started = "Para empezar: añada sus dotfiles con `tuckr push` o añad running_prehook = "Ejecutando prehook" running_posthook = "Ejecutando posthook" symlinking_group = "Haciendo symlink del grupo" -dotfiles_will_be_converted = "Los dotfiles en `%{location}` serán convertidos a Tuckr." dotfiles_created_at = "El directório de dotfiles ha sido creado en `%{location}`." groups_will_be_removed = "Los siguientes grupos serán eliminados" x_available = "%{x} disponíbles" [warn] -want_to_convert_dotfiles = "Está seguro que quiere convertir sus dotfiles para tuckr? (y/N)" want_to_override = "Quiere sustituirlos? (y/N)" want_to_proceed = "Quiere continuar? (y/N)" @@ -38,9 +36,6 @@ make_sure_dir_exists_or_run = "Asegurese de que el directorio `%{dir}` existe o could_not_read_hooks = "No hemos conseguido leer los hooks, el directório podrá no existir o no tiene las permisiones necesárias" failed_to_hook = "El hook ha fallado" got_invalid_group = "Recebimos un grupo inválido: %{hook_group}" -couldnt_create_required_dir = "No ha sido posíble crear el directório obligatorio." -couldnt_open_curr_dir = "No ha sido posíble abrir el directório actual" -couldnt_move_files = "No ha sido posíble mover los ficheros" no_dir_setup_for_x = "No existe un directório creado para %{x}" no_x_setup_yet = "Ningun %{x} ha sido configurado hasta ahora" not_a_tuckr_dotfile = "`%{file}` no es un fichero que pertenece a tuckr." diff --git a/locales/pt-PT.toml b/locales/pt-PT.toml index 5fdb26c..4174f7e 100644 --- a/locales/pt-PT.toml +++ b/locales/pt-PT.toml @@ -10,13 +10,11 @@ how_to_get_started = "Para começar: adicione os seus dotfiles com `tuckr push` running_prehook = "A executar prehook" running_posthook = "A executar posthook" symlinking_group = "A fazer symlink do grupo" -dotfiles_will_be_converted = "Os dotfiles em `%{location}` serão convertidos para Tuckr." dotfiles_created_at = "O diretório de dotfiles foi criado em `%{location}`." groups_will_be_removed = "Os seguintes grupos serão removidos" x_available = "%{x} disponíveis" [warn] -want_to_convert_dotfiles = "Tem a certeza que quer converter os seus dotfiles para tuckr? (y/N)" want_to_override = "Quer substituí-lo? (y/N)" want_to_proceed = "Quer continuar? (y/N)" @@ -38,9 +36,6 @@ make_sure_dir_exists_or_run = "Certifique de que o diretório `%{dir}` existe ou could_not_read_hooks = "Não conseguimos ler os hooks, o diretório poderá não existir ou não ter as permissões necessárias" failed_to_hook = "O hook falhou" got_invalid_group = "Recebemos um grupo inválido: %{hook_group}" -couldnt_create_required_dir = "Não foi possível criar o diretório obrigatório." -couldnt_open_curr_dir = "Não foi possível abrir o diretório atual" -couldnt_move_files = "Não foi possível mover os ficheiros" no_dir_setup_for_x = "Não há um diretório criado para %{x}" no_x_setup_yet = "Ainda nenhum %{x} foi configurado" not_a_tuckr_dotfile = "`%{file}` não é um ficheiro do tuckr." diff --git a/src/fileops.rs b/src/fileops.rs index cf5609c..bfda518 100644 --- a/src/fileops.rs +++ b/src/fileops.rs @@ -7,7 +7,7 @@ use crate::fileops; use owo_colors::OwoColorize; use rust_i18n::t; use std::collections::HashSet; -use std::io::{self, Write}; +use std::io::Write; use std::path::{Path, PathBuf}; use std::process::ExitCode; use std::{fs, path}; @@ -143,68 +143,6 @@ impl Iterator for DirWalk { } } -/// Converts a stow directory into a tuckr directory -pub fn from_stow_cmd(profile: Option, assume_yes: bool) -> Result<(), ExitCode> { - // assume that from_stow is always run from a no profile dotfiles dir - let dotfiles_dir = match dotfiles::get_dotfiles_path(profile) { - Ok(path) => path, - Err(e) => { - eprintln!("{e}"); - return Err(ReturnCode::NoSetupFolder.into()); - } - }; - - // --- Getting user confirmation --- - println!( - "{}", - t!( - "info.dotfiles_will_be_converted", - location = dotfiles_dir.display() - ) - .yellow() - ); - print!("{}", t!("warn.want_to_convert_dotfiles")); - io::stdout().flush().unwrap(); - - if !assume_yes { - let mut answer = String::new(); - io::stdin().read_line(&mut answer).unwrap(); - if !matches!(answer.trim().to_lowercase().as_str(), "yes" | "y") { - return Ok(()); - } - } - - // --- initializing required directory --- - let configs_path = dotfiles_dir.join("Configs"); - fs::create_dir_all(&configs_path).expect(&t!("errors.couldnt_create_required_dir")); - - // --- Moving dotfiles to Configs/ --- - let cwd = fs::read_dir(&dotfiles_dir).expect(&t!("errors.couldnt_open_curr_dir")); - - for file in cwd { - let dir = file.unwrap(); - if !dir.metadata().unwrap().is_dir() { - continue; - } - - let dirname = dir.file_name().to_str().unwrap().to_owned(); - if dirname.starts_with('.') { - continue; - } - - let path = configs_path.join(&dirname); - - if !dirname.ends_with("Configs") - && !dirname.ends_with("Hooks") - && !dirname.ends_with("Secrets") - { - fs::rename(dir.path(), path).expect(&t!("errors.couldnt_move_files")); - } - } - - Ok(()) -} - /// Creates the necessary files and folders for a tuckr directory if they don't exist pub fn init_cmd(profile: Option) -> Result<(), ExitCode> { macro_rules! create_dirs { diff --git a/src/main.rs b/src/main.rs index dd2096b..25cfed8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,12 +149,6 @@ enum Command { /// Creates the files that are necessary to use Tuckr Init, - /// Convert a GNU Stow repo into Tuckr - FromStow { - #[arg(short = 'y', long)] - assume_yes: bool, - }, - /// Return the group files belongs to #[command(name = "groupis", arg_required_else_help = true)] GroupIs { files: Vec }, @@ -202,7 +196,6 @@ fn main() -> ExitCode { Command::Decrypt { groups, exclude } => { secrets::decrypt_cmd(cli.profile, &groups, &exclude) } - Command::FromStow { assume_yes } => fileops::from_stow_cmd(cli.profile, assume_yes), Command::Init => fileops::init_cmd(cli.profile), Command::Ls(ls_type) => match ls_type {