MCPcopy Create free account
hub / github.com/danvk/webdiff / flagsToGitDiffOptions

Function flagsToGitDiffOptions

ts/diff-options.ts:47–65  ·  view source on GitHub ↗
(flags: string[])

Source from the content-addressed store, hash-verified

45}
46
47export function flagsToGitDiffOptions(flags: string[]): Partial<GitDiffOptions> {
48 const options: Partial<GitDiffOptions> = {};
49 for (const flag of flags) {
50 if (flag == '-w' || flag == '--ignore-all-space') {
51 options.ignoreAllSpace = true;
52 } else if (flag == '-b' || flag == '--ignore-space-change') {
53 options.ignoreSpaceChange = true;
54 } else if (flag == '-W' || flag == '--function-context') {
55 options.functionContext = true;
56 } else if (flag.startsWith('--diff-algorithm=')) {
57 // This is pretty imprecise; I believe `--diff-algorithm patience` would also work.
58 const algo = flag.split('=')[1];
59 options.diffAlgorithm = algo as DiffAlgorithm;
60 } else if (flag.startsWith('-U')) {
61 options.unified = Number(flag.slice(2));
62 }
63 }
64 return options;
65}

Callers 2

parseOptionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected