From d3b840facec7bf102b3b653418e4fef24068355c Mon Sep 17 00:00:00 2001 From: Aris van Ommeren Date: Thu, 5 Jan 2023 20:45:28 +0100 Subject: [PATCH 1/2] Add `category`/`-c` option --- cli.js | 11 +++++++++-- index.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index 4aaeb84..1cc8081 100755 --- a/cli.js +++ b/cli.js @@ -24,7 +24,7 @@ var args = utils.minimist(process.argv.slice(2), { string: ['e'], string: ['p'], string: ['b'], - alias: {h: 'help'} + string: ['c'], }); if (!args.d && !args.i && !args.p && (args._.length==0) || args.h) { @@ -51,6 +51,9 @@ if (!args.d && !args.i && !args.p && (args._.length==0) || args.h) { ' Supports: asterisk, dash, plus', ' (Default is asterisk)', '', + ' -c Add a category for the ADR', + ' (Default is empty)', + '', ' -h: Shows how to use this program', '' ].join(os.EOL)); @@ -66,6 +69,10 @@ var defaultAdrLogDir = path.resolve(process.cwd()); var adrLogDir = args.d || defaultAdrLogDir; var adrPathPrefix = args.p || ''; var adrBulletStyle = args.b || ''; +var adrCategory = '' +if (args.c) { + adrCategory += args.c + '-'; +} var defaultAdrLogFile = 'index.md'; var adrLogFile = args._[0] || adrLogDir + '/' + defaultAdrLogFile; @@ -99,7 +106,7 @@ if (fs.existsSync(adrLogFile)) { } else { existingLogString = '' + os.EOL + os.EOL + '' + os.EOL; } -var newLogString = toc.insertAdrToc(existingLogString, headings, {pathPrefix: adrPathPrefix, dir: adrLogDir, bulletStyle: adrBulletStyle, tocDir}); +var newLogString = toc.insertAdrToc(existingLogString, headings, { pathPrefix: adrPathPrefix, dir: adrLogDir, bulletStyle: adrBulletStyle, category: adrCategory, tocDir }); if (args.i) { fs.writeFileSync(adrLogFile, newLogString); diff --git a/index.js b/index.js index 154ea5a..60b6613 100644 --- a/index.js +++ b/index.js @@ -110,7 +110,7 @@ function generate(options) { console.log("title before decimal removal: ", title); title = title.replace(/^\d+\. /, ''); console.log("title after decimal removal: ", title); - res.content += `${options.bulletChar} [ADR-${index.trim()}](${options.pathPrefix}${tokenPath}) - ${title + options.newline}` + res.content += `${options.bulletChar} [ADR-${options.category}${index.trim()}](${options.pathPrefix}${tokenPath}) - ${title + options.newline}` } res.content = res.content.trim(); return res; From dba4b049e684318c1ddc56693a8bb3c9848f6ea7 Mon Sep 17 00:00:00 2001 From: Aris van Ommeren Date: Thu, 5 Jan 2023 20:49:39 +0100 Subject: [PATCH 2/2] Update docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d918347..3480411 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ Usage: adr-log [-d ] [-i ] [-p ] -b Change the character used to for bullets Supports: asterisk, dash, plus (Default is asterisk) + + -c Add a category for the ADR + (Default is empty) -h: Shows how to use this program ```