Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add category/-c option #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ Usage: adr-log [-d <directory>] [-i <input>] [-p <path_prefix>]
-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
```
Expand Down
11 changes: 9 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -99,7 +106,7 @@ if (fs.existsSync(adrLogFile)) {
} else {
existingLogString = '<!-- adrlog -->' + os.EOL + os.EOL + '<!-- adrlogstop -->' + 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);
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down