Skip to content

Commit 8600a1b

Browse files
AliiiBennclaude
andcommitted
fix: Correct strip command flag logic for left/right options
- Change --left and --right flags to default to False - Update logic to strip both sides when neither flag is specified (default behavior) - Fix strip mode display to show correct side - Fix test_strip_left_only and test_strip_both_sides Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 04a1446 commit 8600a1b

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

excel_toolkit/commands/strip.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def strip(
2323
"-c",
2424
help="Columns to strip (comma-separated, default: all string columns)",
2525
),
26-
left: bool = typer.Option(True, "--left", help="Strip leading whitespace (default: True)"),
27-
right: bool = typer.Option(True, "--right", help="Strip trailing whitespace (default: True)"),
26+
left: bool = typer.Option(False, "--left", help="Strip leading whitespace only"),
27+
right: bool = typer.Option(False, "--right", help="Strip trailing whitespace only"),
2828
output: str | None = typer.Option(None, "--output", "-o", help="Output file path"),
2929
sheet: str | None = typer.Option(None, "--sheet", "-s", help="Sheet name for Excel files"),
3030
) -> None:
@@ -72,14 +72,19 @@ def strip(
7272
cells_modified += df[col].str.rstrip().ne(df[col]).sum()
7373

7474
# 5. Determine strip side
75-
if left and right:
75+
# Default: if neither flag specified, strip both sides
76+
if not left and not right:
7677
side = "both"
78+
side_display = "left/right"
79+
elif left and right:
80+
side = "both"
81+
side_display = "left/right"
7782
elif left:
7883
side = "left"
79-
elif right:
84+
side_display = "left"
85+
else: # right only
8086
side = "right"
81-
else:
82-
side = "both"
87+
side_display = "right"
8388

8489
# 6. Strip whitespace using operation
8590
result = trim_whitespace(df, columns=column_list, side=side)
@@ -99,9 +104,7 @@ def strip(
99104
else:
100105
typer.echo(f"All string columns: {', '.join(column_list)}")
101106
typer.echo(f"Cells modified: {cells_modified}")
102-
typer.echo(
103-
f"Strip mode: {'left' if left else ''}{'/' if left and right else ''}{'right' if right else ''}"
104-
)
107+
typer.echo(f"Strip mode: {side_display}")
105108
typer.echo("")
106109

107110
# 8. Write or display

0 commit comments

Comments
 (0)