Skip to content

Commit

Permalink
Merge pull request #134 from maxvisser/feature/added-file-content-toggle
Browse files Browse the repository at this point in the history
Added viewed checkbox to toggle file content by default on true
  • Loading branch information
rtfpessoa authored Jun 3, 2022
2 parents 962ee9c + 58526eb commit f9044e3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
4 changes: 4 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();` : '',
Expand Down
1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/yargs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {

export type Argv = {
style: StyleType;
fileContentToggle: boolean;
synchronisedScroll: boolean;
highlightCode: boolean;
diffStyle: DiffStyleType;
Expand All @@ -38,6 +39,7 @@ export type Argv = {

const defaults: Argv = {
style: 'line',
fileContentToggle: true,
synchronisedScroll: true,
highlightCode: true,
summary: 'closed',
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
const targetElement = document.getElementById('diff');
const diff2htmlUi = new Diff2HtmlUI(targetElement);
//diff2html-fileListToggle
//diff2html-fileContentToggle
//diff2html-synchronisedScroll
//diff2html-highlightCode
});
Expand Down

0 comments on commit f9044e3

Please sign in to comment.