diff --git a/translator/bat2cat/translator.go b/translator/bat2cat/translator.go index d633891..a1edf25 100644 --- a/translator/bat2cat/translator.go +++ b/translator/bat2cat/translator.go @@ -150,6 +150,11 @@ func handleShortFlags(arg string, args []string, i int, result *[]string, skipNe } else { // Flags without direct mapping or bat-specific flags switch flag { + case 'v': + // -v (display non-printing as ^X / M-x) — approximated with --show-all + // and caret notation. Note: bat also visualizes spaces/newlines which + // cat -v does not, but this is the closest available approximation. + *result = append(*result, "--show-all", "--nonprintable-notation=caret") case 'p': // -p (plain) is already added by default, ignore case 'l', 'H', 'm': diff --git a/translator/bat2cat/translator_test.go b/translator/bat2cat/translator_test.go index 4085ae3..74a9f86 100644 --- a/translator/bat2cat/translator_test.go +++ b/translator/bat2cat/translator_test.go @@ -70,6 +70,13 @@ func TestTranslateFlags(t *testing.T) { expected: []string{"-p", "--paging=never", "--color=auto", "-u", "file.txt"}, }, + // Show non-printing (approximate: also shows spaces/newlines) + { + name: "show non-printing", + input: []string{"-v", "file.txt"}, + expected: []string{"-p", "--paging=never", "--color=auto", "--show-all", "--nonprintable-notation=caret", "file.txt"}, + }, + // Combined flags { name: "combined flags", @@ -81,6 +88,21 @@ func TestTranslateFlags(t *testing.T) { input: []string{"-nsu", "file.txt"}, expected: []string{"-p", "--paging=never", "--color=auto", "-n", "-s", "-u", "file.txt"}, }, + { + name: "non-printing with line numbers", + input: []string{"-vn", "file.txt"}, + expected: []string{"-p", "--paging=never", "--color=auto", "--show-all", "--nonprintable-notation=caret", "-n", "file.txt"}, + }, + { + name: "non-printing with squeeze and unbuffered", + input: []string{"-vsu", "file.txt"}, + expected: []string{"-p", "--paging=never", "--color=auto", "--show-all", "--nonprintable-notation=caret", "-s", "-u", "file.txt"}, + }, + { + name: "non-printing as separate flag with others", + input: []string{"-n", "-v", "-s", "file.txt"}, + expected: []string{"-p", "--paging=never", "--color=auto", "-n", "--show-all", "--nonprintable-notation=caret", "-s", "file.txt"}, + }, // bat-specific flags that are ignored or overridden {