diff --git a/src/main.ts b/src/main.ts index 1bf7e9a..005c3aa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,6 +5,7 @@ import { Utils } from './utils'; export interface Settings { outputFileName: string; + includeHeader: boolean; disableWorkingLinks: boolean; directoriesToIgnore: string[]; filesToIgnore: string[]; @@ -23,10 +24,12 @@ export interface Settings { withoutTagsDirectoriesToIgnore: string[]; withoutTagsFilesToIgnore: string[]; withoutTagsOutputFileName: string; + withoutTagsIncludeHeader: boolean; openOutputFile: boolean; } const DEFAULT_SETTINGS: Settings = { outputFileName: "orphaned files output", + includeHeader: false, disableWorkingLinks: false, directoriesToIgnore: [], filesToIgnore: [], @@ -45,6 +48,7 @@ const DEFAULT_SETTINGS: Settings = { withoutTagsDirectoriesToIgnore: [], withoutTagsFilesToIgnore: [], withoutTagsOutputFileName: "files without tags", + withoutTagsIncludeHeader: false, openOutputFile: true, }; @@ -114,6 +118,8 @@ export default class FindOrphanedFilesPlugin extends Plugin { let text = ""; + if (this.settings.includeHeader) + text += "# " + this.settings.outputFileName + "\n"; let prefix: string; if (this.settings.disableWorkingLinks) prefix = " "; @@ -217,7 +223,10 @@ export default class FindOrphanedFilesPlugin extends Plugin { prefix = " "; else prefix = ""; - const text = withoutFiles.map((file) => `${prefix}- [[${file.path}]]`).join("\n"); + let text = ""; + if (this.settings.withoutTagsIncludeHeader) + text += "# " + this.settings.withoutTagsOutputFileName + "\n"; + text += withoutFiles.map((file) => `${prefix}- [[${file.path}]]`).join("\n"); Utils.writeAndOpenFile(this.app, outFileName, text, this.settings.openOutputFile); } diff --git a/src/settingsTab.ts b/src/settingsTab.ts index 2e1a908..efa1032 100644 --- a/src/settingsTab.ts +++ b/src/settingsTab.ts @@ -47,6 +47,15 @@ export class SettingsTab extends PluginSettingTab { this.plugin.saveSettings(); }).setValue(this.plugin.settings.outputFileName)); + new Setting(containerEl) + .setName('Include Header') + .setDesc('Include a header at the top of the file (same as the output file name)') + .addToggle(cb => cb.onChange(value => { + this.plugin.settings.includeHeader = value; + this.plugin.saveSettings(); + } + ).setValue(this.plugin.settings.includeHeader)); + new Setting(containerEl) .setName('Disable working links') .setDesc('Indent lines to disable the link and to clean up the graph view') @@ -228,6 +237,15 @@ export class SettingsTab extends PluginSettingTab { this.plugin.saveSettings(); }).setValue(this.plugin.settings.withoutTagsOutputFileName)); + new Setting(containerEl) + .setName('Include Header') + .setDesc('Include a header at the top of the file (same as the output file name)') + .addToggle(cb => cb.onChange(value => { + this.plugin.settings.withoutTagsIncludeHeader = value; + this.plugin.saveSettings(); + } + ).setValue(this.plugin.settings.withoutTagsIncludeHeader)); + new Setting(containerEl) .setName("Exclude files") .setDesc("Exclude the specific files. Add each file path in a new line (with file extension!)")