Skip to content

Commit f7771fa

Browse files
codewizdaveclaude
andcommitted
fix: Add --rules parameter and improve validate command
- Add --rules parameter to support validation rule shorthand format - Add --rules-file parameter to load rules from JSON file - Add --output parameter to write validation report to file - Implement email pattern validation for 'email:email' rules - Implement wildcard '*' rule to validate all columns - Show type mismatches as warnings instead of errors - Fix exit code logic to only fail on critical errors - Handle empty files gracefully - Add comprehensive report structure with file metadata Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 0a9a6ae commit f7771fa

3 files changed

Lines changed: 301 additions & 23 deletions

File tree

excel_toolkit/commands/head.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,15 @@ def head(
4141
format: Output format: table, csv, or json
4242
4343
Raises:
44-
typer.Exit: If file cannot be read
44+
typer.Exit: If file cannot be read or invalid format
4545
"""
46+
# 0. Validate format
47+
valid_formats = ["table", "csv", "json"]
48+
if format not in valid_formats:
49+
typer.echo(f"Unknown format: {format}", err=True)
50+
typer.echo(f"Supported formats: {', '.join(valid_formats)}", err=True)
51+
raise typer.Exit(1)
52+
4653
# 1. Read file
4754
df = read_data_file(file_path, sheet)
4855

@@ -60,7 +67,7 @@ def head(
6067

6168
# 5. Display file info
6269
path = Path(file_path)
63-
format_file_info(path, len(df), len(df.columns))
70+
typer.echo(format_file_info(str(path), sheet=sheet, total_rows=len(df), total_cols=len(df.columns)))
6471

6572
# 6. Show column information if requested
6673
if show_columns:

0 commit comments

Comments
 (0)