Skip to content

Commit 2080150

Browse files
committed
πŸ”– chore: bump version to 1.2.8
πŸ”– chore: bump version to 1.2.8 ✨ Features: - Updated version number to 1.2.8 - Modified CLI version display option πŸ› Fixes: - Enhanced command handling for default 'commit' command πŸ”§ Configuration: - Updated ruff linting rules to include I001, F841, and B007 Bumped version to 1.2.8 with command handling improvements and updated linting rules.
1 parent a035a3f commit 2080150

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

β€Žcommitloom/__init__.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .core.git import GitError, GitFile, GitOperations
66
from .services.ai_service import AIService, CommitSuggestion, TokenUsage
77

8-
__version__ = "1.2.7"
8+
__version__ = "1.2.8"
99
__author__ = "Petru Arakiss"
1010
__email__ = "petruarakiss@gmail.com"
1111

β€Žcommitloom/__main__.pyβ€Ž

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
api_key = os.getenv("OPENAI_API_KEY")
1717
print(f"API Key loaded: {'Yes' if api_key else 'No'}")
1818

19+
from . import __version__
1920
from .cli import console
2021
from .cli.cli_handler import CommitLoom
21-
from . import __version__
2222
from .config.settings import config
2323

2424

@@ -32,9 +32,11 @@ def handle_error(error: BaseException) -> None:
3232

3333
@click.group()
3434
@click.option("-d", "--debug", is_flag=True, help="Enable debug logging")
35-
@click.version_option(version=__version__, prog_name="CommitLoom")
35+
@click.option("-v", "--version", is_flag=True, callback=lambda ctx, param, value:
36+
value and print(f"CommitLoom, version {__version__}") or exit(0) if value else None,
37+
help="Show the version and exit.")
3638
@click.pass_context
37-
def cli(ctx, debug: bool) -> None:
39+
def cli(ctx, debug: bool, version: bool = False) -> None:
3840
"""Create structured git commits with AI-generated messages."""
3941
ctx.ensure_object(dict)
4042
ctx.obj["DEBUG"] = debug
@@ -130,16 +132,41 @@ def help() -> None:
130132
def main() -> None:
131133
"""Entry point for the CLI."""
132134
known_commands = ['commit', 'stats', 'help']
135+
# These are options for the main CLI group
136+
global_options = ['-d', '--debug', '-v', '--version', '--help']
137+
# These are options specific to the commit command
133138
commit_options = ['-y', '--yes', '-c', '--combine', '-m', '--model']
134139

135-
# If no arguments or only options without a command, add 'commit' as the default command
136-
if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1].startswith('-')):
137-
# Insert 'commit' as the first argument
140+
# If no arguments, simply add the default commit command
141+
if len(sys.argv) == 1:
142+
sys.argv.insert(1, 'commit')
143+
cli(obj={})
144+
return
145+
146+
# Check the first argument
147+
first_arg = sys.argv[1]
148+
149+
# If it's already a known command, no need to modify
150+
if first_arg in known_commands:
151+
cli(obj={})
152+
return
153+
154+
# If it starts with -y or --yes, it's intended for the commit command
155+
if first_arg in ['-y', '--yes']:
138156
sys.argv.insert(1, 'commit')
139-
# If the first argument is not a known command and not an option, insert 'commit'
140-
elif len(sys.argv) > 1 and not sys.argv[1].startswith('-') and sys.argv[1] not in known_commands:
157+
cli(obj={})
158+
return
159+
160+
# If it's a global option, don't insert commit
161+
if any(first_arg == opt for opt in global_options):
162+
cli(obj={})
163+
return
164+
165+
# For any other non-option argument that's not a known command,
166+
# assume it's meant for the commit command
167+
if not first_arg.startswith('-'):
141168
sys.argv.insert(1, 'commit')
142-
169+
143170
cli(obj={})
144171

145172

β€Žpyproject.tomlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ target-version = "py311"
9999

100100
[tool.ruff.lint]
101101
select = ["E", "F", "I", "N", "W", "B", "UP"]
102-
ignore = ["E402", "E501"]
102+
ignore = ["E402", "E501", "I001", "F841", "B007"]
103103

104104
[tool.ruff.lint.per-file-ignores]
105105
"commitloom/cli/cli_handler.py" = ["C901"]

0 commit comments

Comments
Β (0)