Skip to content

fix(sem-cli): diff --format now uses the OutputFormat Enum directly#92

Merged
rs545837 merged 3 commits intoAtaraxy-Labs:mainfrom
Benjas333:fix/format-enum
Apr 24, 2026
Merged

fix(sem-cli): diff --format now uses the OutputFormat Enum directly#92
rs545837 merged 3 commits intoAtaraxy-Labs:mainfrom
Benjas333:fix/format-enum

Conversation

@Benjas333
Copy link
Copy Markdown
Contributor

@Benjas333 Benjas333 commented Apr 24, 2026

Changelog

Changed

  • diff --format now uses OutputFormat directly.

Removed

  • Removed repeated docs (clap already prints possible values)

CLI Help Output

sem diff -h
@@ -13,9 +13,9 @@
       --to <TO>                   End of commit range
       --stdin                     Read FileChange[] JSON from stdin instead of git
       --patch                     Read unified diff from stdin (e.g. git diff | sem diff --patch)
-      --format <FORMAT>           Output format: terminal, json, or markdown [default: terminal]
+      --format <FORMAT>           Output format [default: terminal] [possible values: terminal, plain, json, markdown]
   -v, --verbose                   Show inline content diffs for each entity
       --file-exts <FILE_EXTS>...  Only include files with these extensions (e.g. --file-exts .py .rs)
-      --color <COLOR>             When to use colors: always, auto, never [default: auto] [possible values: always, auto, never]
+      --color <COLOR>             When to use colors [default: auto] [possible values: always, auto, never]
   -C, --cwd <DIRECTORY>           Run as if started in this directory (like git -C)
   -h, --help                      Print help

Shell Completions

This also fixes the generated shell completions

sem completions nushell
@@ -6,6 +6,10 @@
     --version(-V)             # Print version
   ]

+  def "nu-complete sem diff format" [] {
+    [ "terminal" "plain" "json" "markdown" ]
+  }
+
   def "nu-complete sem diff color" [] {
     [ "always" "auto" "never" ]
   }
@@ -19,11 +23,11 @@
     --to: string              # End of commit range
     --stdin                   # Read FileChange[] JSON from stdin instead of git
     --patch                   # Read unified diff from stdin (e.g. git diff | sem diff --patch)
-    --format: string          # Output format: terminal, json, or markdown
+    --format: string@"nu-complete sem diff format" # Output format
     --verbose(-v)             # Show inline content diffs for each entity
     --profile                 # Show internal timing profile
     --file-exts: string       # Only include files with these extensions (e.g. --file-exts .py .rs)
-    --color: string@"nu-complete sem diff color" # When to use colors: always, auto, never
+    --color: string@"nu-complete sem diff color" # When to use colors
     --cwd(-C): string         # Run as if started in this directory (like git -C)
     --help(-h)                # Print help
     ...args: string           # Git refs, files, or pathspecs (supports ref1..ref2, ref1...ref2, -- paths)

Proper Error Output

Before, an invalid format would fall back to Terminal. Now it throws a proper error including all the valid values.

sem diff --format foo
error: invalid value 'foo' for '--format <FORMAT>'
  [possible values: terminal, plain, json, markdown]

For more information, try '--help'.

removed repeated docs (clap already prints possible values)
Copy link
Copy Markdown

@inspect-review inspect-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspect review

Triage: 2 entities analyzed | 0 critical, 0 high, 2 medium, 0 low
Verdict: standard_review

Findings (1)

  1. [low] --format no longer accepts previously supported alias md (and any other non-canonical values) because the manual mapping ("markdown" | "md" => OutputFormat::Markdown) was removed and format is now parsed directly as OutputFormat via clap::ValueEnum with no alias annotations in the diff. This is a breaking CLI behavior change for scripts/users relying on --format md. Evidence: removed match arm for "md"; added #[derive(..., clap::ValueEnum)] and changed format: String -> format: OutputFormat.

Reviewed by inspect | Entity-level triage found 0 high-risk changes

@Benjas333 Benjas333 marked this pull request as draft April 24, 2026 06:47
@Benjas333
Copy link
Copy Markdown
Contributor Author

Benjas333 commented Apr 24, 2026

Oh, I didn't notice the md alias

Copy link
Copy Markdown

@inspect-review inspect-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspect review

Triage: 3 entities analyzed | 0 critical, 0 high, 3 medium, 0 low
Verdict: standard_review

Findings (0)


Reviewed by inspect | Entity-level triage found 0 high-risk changes

@Benjas333 Benjas333 marked this pull request as ready for review April 24, 2026 06:55
Copy link
Copy Markdown

@inspect-review inspect-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inspect review

Triage: 3 entities analyzed | 0 critical, 0 high, 3 medium, 0 low
Verdict: standard_review

Findings (1)

  1. [low] CLI behavior change: unknown --format values previously fell back to Terminal, but now format: OutputFormat (with clap::ValueEnum) will cause clap to reject invalid values at argument parsing time (removed _ => OutputFormat::Terminal fallback in main.rs). Evidence: format: String + manual match ... _ => OutputFormat::Terminal removed; replaced with format: OutputFormat and passed through directly.

Reviewed by inspect | Entity-level triage found 0 high-risk changes

@rs545837 rs545837 merged commit ff190e2 into Ataraxy-Labs:main Apr 24, 2026
1 check passed
@rs545837
Copy link
Copy Markdown
Member

Thanks for reporting this and opening the PR.

@Benjas333 Benjas333 deleted the fix/format-enum branch April 24, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants