Skip to content

Commit

Permalink
pref: add config command after running init command
Browse files Browse the repository at this point in the history
  • Loading branch information
Undertone0809 committed Jun 29, 2024
1 parent 4ab9d7f commit c80a9d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
29 changes: 16 additions & 13 deletions gcop/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
Expand Down

0 comments on commit c80a9d2

Please sign in to comment.