From c80a9d25f98067e13fa8d21339159d942ba04399 Mon Sep 17 00:00:00 2001 From: zeeland Date: Sat, 29 Jun 2024 20:50:32 +0800 Subject: [PATCH] pref: add config command after running init command --- gcop/__main__.py | 29 ++++++++++++++++------------- pyproject.toml | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/gcop/__main__.py b/gcop/__main__.py index 15fa576..39ef21d 100644 --- a/gcop/__main__.py +++ b/gcop/__main__.py @@ -95,6 +95,19 @@ def generate_commit_message(diff: str) -> str: return response.content +@app.command(name="config") +def config_command(): + """Open the config file in the default editor.""" + initial_content = ( + "model:\n model_name: provider/name,eg openai/gpt-4o" + "\n api_key: your_api_key\n" + ) + if not os.path.exists(gcop_config.config_path): + Path(gcop_config.config_path).write_text(initial_content) + + click.edit(filename=gcop_config.config_path) + + @app.command(name="init") def init_command(): """Add command into git config""" @@ -114,24 +127,14 @@ def init_command(): check=True, encoding="utf-8", # noqa ) + console.print("[green]git aliases added successfully[/]") + + config_command() console.print("[green]gcop initialized successfully[/]") except subprocess.CalledProcessError as error: print(f"Error adding git aliases: {error}") -@app.command(name="config") -def config_command(): - """Open the config file in the default editor.""" - initial_content = ( - "model:\n model_name: provider/name,eg openai/gpt-4o" - "\n api_key: your_api_key\n" - ) - if not os.path.exists(gcop_config.config_path): - Path(gcop_config.config_path).write_text(initial_content) - - click.edit(filename=gcop_config.config_path) - - @app.command(name="commit") def commit_command(): """Generate a git commit message based on the staged changes and commit the diff --git a/pyproject.toml b/pyproject.toml index 3cf064b..382541e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires = ["poetry-core"] [tool.poetry] name = "gcop" -version = "1.0.0" +version = "1.0.1" description = "gcop is your git AI copilot." readme = "README.md" authors = ["gcop "]