diff --git a/script/todo/todo.json b/script/todo/todo.json index 90a52a7..256c02b 100644 --- a/script/todo/todo.json +++ b/script/todo/todo.json @@ -52,5 +52,10 @@ "makefile_cmd": "format" } ], - "git_from_makefile": [] + "git_from_makefile": [ + { + "prompt_description_key": "git_config_vim", + "bash_command": "git config --global core.editor \"vim\"" + } + ] } diff --git a/script/todo/todo.py b/script/todo/todo.py index 98a27d6..f646eb7 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -456,6 +456,13 @@ class TODO: db_name, extra_cmd_web_login=extra_cmd_web_login ) + bash_command = instance.get("bash_command") + if bash_command: + print(f"{t('will_execute')} {bash_command}") + self.execute.exec_command_live( + bash_command, source_erplibre=False + ) + command = instance.get("command") if command: self.prompt_execute_selenium( @@ -661,6 +668,7 @@ class TODO: print(f"🤖 {t('git_manage')}") choices = [ {"prompt_description": t("git_local_server")}, + {"prompt_description": t("git_add_remote")}, ] # Append config-driven entries @@ -677,6 +685,8 @@ class TODO: return False elif status == "1": self.prompt_execute_git_local_server() + elif status == "2": + self._git_add_remote() else: cmd_no_found = True try: @@ -690,6 +700,24 @@ class TODO: if cmd_no_found: print(t("cmd_not_found")) + def _git_add_remote(self): + remote_name = ( + input(t("git_add_remote_name_prompt")).strip() or "localhost" + ) + remote_url = input(t("git_add_remote_url_prompt")).strip() + if not remote_url: + print(t("git_add_remote_url_required")) + return + cmd = f"git remote add {remote_name} {remote_url}" + print(f"{t('will_execute')} {cmd}") + try: + self.execute.exec_command_live( + cmd, source_erplibre=False + ) + print(t("git_add_remote_success")) + except Exception as e: + print(f"{t('git_add_remote_error')}{e}") + def prompt_execute_git_local_server(self): print(f"🤖 {t('git_repo_manage')}") choices = [ @@ -775,6 +803,7 @@ class TODO: print(f"🤖 {t('gpt_code_manage')}") choices = [ {"prompt_description": t("gpt_code_claude_commit")}, + {"prompt_description": t("gpt_code_claude_add_automation")}, {"prompt_description": t("menu_rtk")}, ] help_info = self.fill_help_info(choices) @@ -787,6 +816,8 @@ class TODO: elif status == "1": self._setup_claude_commit() elif status == "2": + self._claude_add_automation() + elif status == "3": self.prompt_execute_rtk() else: print(t("cmd_not_found")) @@ -830,6 +861,45 @@ class TODO: except Exception as e: print(f"{t('gpt_code_commit_error')}{e}") + def _claude_add_automation(self): + description = input( + t("gpt_code_claude_add_automation_prompt") + ).strip() + if not description: + return + command = input( + t("gpt_code_claude_add_automation_cmd_prompt") + ).strip() + if not command: + return + section = ( + input( + t("gpt_code_claude_add_automation_section_prompt") + ).strip() + or "git" + ) + section_key = f"{section}_from_makefile" + config_path = os.path.join( + os.path.dirname(__file__), "todo.json" + ) + try: + with open(config_path) as f: + config = json.load(f) + if section_key not in config: + config[section_key] = [] + config[section_key].append( + { + "prompt_description": description, + "bash_command": command, + } + ) + with open(config_path, "w") as f: + json.dump(config, f, indent=4, ensure_ascii=False) + f.write("\n") + print(t("gpt_code_claude_add_automation_success")) + except Exception as e: + print(f"{t('gpt_code_claude_add_automation_error')}{e}") + def prompt_execute_doc(self): print(f"🤖 {t('doc_search')}") choices = [ diff --git a/script/todo/todo_i18n.py b/script/todo/todo_i18n.py index 9310329..77387f7 100644 --- a/script/todo/todo_i18n.py +++ b/script/todo/todo_i18n.py @@ -558,6 +558,69 @@ TRANSLATIONS = { "fr": "Serve - Démarrer le daemon git", "en": "Serve - Start git daemon", }, + # Git remote add + "git_add_remote": { + "fr": "Ajouter un remote vers un dépôt local", + "en": "Add a remote to a local repository", + }, + "git_add_remote_name_prompt": { + "fr": "Nom du remote (défaut: localhost) : ", + "en": "Remote name (default: localhost): ", + }, + "git_add_remote_url_prompt": { + "fr": "Adresse du dépôt (ex: git://192.168.1.100/mon-repo.git) : ", + "en": "Repository address (e.g.: git://192.168.1.100/my-repo.git): ", + }, + "git_add_remote_url_required": { + "fr": "L'adresse du dépôt est requise!", + "en": "Repository address is required!", + }, + "git_add_remote_success": { + "fr": "Remote ajouté avec succès!", + "en": "Remote added successfully!", + }, + "git_add_remote_error": { + "fr": "Erreur lors de l'ajout du remote : ", + "en": "Error adding remote: ", + }, + # Git config vim + "git_config_vim": { + "fr": "Configuration git local par vim", + "en": "Configure git local editor to vim", + }, + "git_config_vim_success": { + "fr": "Éditeur git configuré sur vim avec succès!", + "en": "Git editor configured to vim successfully!", + }, + "git_config_vim_error": { + "fr": "Erreur lors de la configuration : ", + "en": "Error during configuration: ", + }, + # GPT code - Claude automation + "gpt_code_claude_add_automation": { + "fr": "Ajouter une automatisation avec Claude dans todo.py", + "en": "Add an automation with Claude in todo.py", + }, + "gpt_code_claude_add_automation_prompt": { + "fr": "Description de la commande à ajouter : ", + "en": "Description of the command to add: ", + }, + "gpt_code_claude_add_automation_cmd_prompt": { + "fr": "Commande bash à exécuter : ", + "en": "Bash command to execute: ", + }, + "gpt_code_claude_add_automation_section_prompt": { + "fr": "Section du menu (git/code/config/network/process) : ", + "en": "Menu section (git/code/config/network/process): ", + }, + "gpt_code_claude_add_automation_success": { + "fr": "Automatisation ajoutée avec succès dans todo.json!", + "en": "Automation added successfully in todo.json!", + }, + "gpt_code_claude_add_automation_error": { + "fr": "Erreur lors de l'ajout de l'automatisation : ", + "en": "Error adding automation: ", + }, # Language selection "lang_prompt": { "fr": "Choisir la langue / Choose language",