Skip to content

Commit 134bb4b

Browse files
committed
⚙️ fix: refine command parsing logic in main
⚙️ fix: refine command parsing logic in main 🐛 Bug Fixes: - Changed condition to check any commit-specific option instead of only '-y'/'--yes' - Fixed debug option handling to insert 'commit' only when next argument is not a known command ✨ Enhancements: - Added explicit handling for global options to prevent inserting 'commit' command - Reorganized conditional flow for clearer command insertion logic Improved command line argument parsing to correctly handle commit, global, and debug options
1 parent 8cb8633 commit 134bb4b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

commitloom/__main__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,26 @@ def main() -> None:
155155
cli(obj={})
156156
return
157157

158-
# If it starts with -y or --yes, it's intended for the commit command
159-
if first_arg in ['-y', '--yes']:
158+
# If it starts with any commit-specific option, it's intended for the commit command
159+
if first_arg in commit_options:
160160
sys.argv.insert(1, 'commit')
161161
cli(obj={})
162162
return
163163

164+
# If it's a global option, don't insert commit
165+
if any(first_arg == opt for opt in global_options):
166+
cli(obj={})
167+
return
168+
164169
# If it's a debug option, add 'commit' after it to enable debugging for the commit command
165170
if first_arg in debug_options:
166171
# Check if there's a command after the debug flag
167-
if len(sys.argv) <= 2 or (len(sys.argv) > 2 and sys.argv[2].startswith('-')):
172+
if len(sys.argv) <= 2 or (len(sys.argv) > 2 and (sys.argv[2].startswith('-') and sys.argv[2] not in known_commands)):
168173
# No command after debug flag, insert commit
169174
sys.argv.insert(2, 'commit')
170175
cli(obj={})
171176
return
172177

173-
# If it's a global option, don't insert commit
174-
if any(first_arg == opt for opt in global_options):
175-
cli(obj={})
176-
return
177-
178178
# For any other non-option argument that's not a known command,
179179
# assume it's meant for the commit command
180180
if not first_arg.startswith('-'):

0 commit comments

Comments
 (0)