diff --git a/README.md b/README.md index a365d11..9ea3709 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Usage: diff2html [ flags and/or options ] -- [git diff passthrough flags and opt | flag | alias | description | choices | default | | ----- | --------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------- | --------- | | -s | --style | Output style | `line`, `side` | `line` | +| --fct | --fileContentToggle | Adds a viewed checkbox to toggle file content | `true`, `false` | `true` | | --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` | | --hc | --highlightCode | Highlight code | `true`, `false` | `true` | | --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` | diff --git a/src/cli.ts b/src/cli.ts index 5132b58..d51845c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -64,6 +64,10 @@ function prepareHTML(diffHTMLContent: string, config: Configuration): string { searchValue: '//diff2html-fileListToggle', replaceValue: `diff2htmlUi.fileListToggle(${config.showFilesOpen});`, }, + { + searchValue: '//diff2html-fileContentToggle', + replaceValue: config.fileContentToggle ? `diff2htmlUi.fileContentToggle();` : '', + }, { searchValue: '//diff2html-synchronisedScroll', replaceValue: config.synchronisedScroll ? `diff2htmlUi.synchronisedScroll();` : '', diff --git a/src/configuration.ts b/src/configuration.ts index 17d17a5..535cc51 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -38,6 +38,7 @@ export function parseArgv(argv: Argv): [Diff2HtmlConfig, Configuration] { const defaultWrapperTemplate = path.resolve(__dirname, '..', 'template.html'); const configuration: Configuration = { showFilesOpen: argv.summary === 'open' || false, + fileContentToggle: argv.fileContentToggle, synchronisedScroll: argv.synchronisedScroll, highlightCode: argv.highlightCode, formatType: argv.format, diff --git a/src/types.ts b/src/types.ts index 9ec24d7..0de3673 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,6 +8,7 @@ export type OutputType = 'preview' | 'stdout'; export type DiffyType = 'browser' | 'pbcopy' | 'print'; export type Configuration = { + fileContentToggle: boolean; synchronisedScroll: boolean; showFilesOpen: boolean; highlightCode: boolean; diff --git a/src/yargs.ts b/src/yargs.ts index 45e90ac..0a326e9 100644 --- a/src/yargs.ts +++ b/src/yargs.ts @@ -13,6 +13,7 @@ import { export type Argv = { style: StyleType; + fileContentToggle: boolean; synchronisedScroll: boolean; highlightCode: boolean; diffStyle: DiffStyleType; @@ -38,6 +39,7 @@ export type Argv = { const defaults: Argv = { style: 'line', + fileContentToggle: true, synchronisedScroll: true, highlightCode: true, summary: 'closed', @@ -93,6 +95,12 @@ export function setup(): Argv { choices: choices.style, default: defaults.style, }) + .option('fileContentToggle', { + alias: 'fct', + describe: 'Show viewed checkbox to toggle file content', + type: 'boolean', + default: defaults.fileContentToggle, + }) .option('synchronisedScroll', { alias: 'sc', describe: 'Synchronised horizontal scroll', diff --git a/template.html b/template.html index 4ef91d9..38ec330 100644 --- a/template.html +++ b/template.html @@ -20,6 +20,7 @@ const targetElement = document.getElementById('diff'); const diff2htmlUi = new Diff2HtmlUI(targetElement); //diff2html-fileListToggle + //diff2html-fileContentToggle //diff2html-synchronisedScroll //diff2html-highlightCode });