Skip to content

Commit 31c7a4d

Browse files
ziv-codefreshitai-codefresh
authored andcommitted
add alias option (#152)
1 parent 7753189 commit 31c7a4d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

docs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const createCommandFile = async (nestedCategory,docs) => {
132132
// ARGUMENTS string
133133
docs.command.shift();
134134
if (docs.positionals.length) {
135-
const argumentsString = `### Arguments\n\nOption | Default | Description\n--------- | ----------- | -----------\n${docs.positionals}`;
135+
const argumentsString = `### Arguments\n\nOption | Alias | Default | Description\n--------- | --------- | ----------- | -----------\n${docs.positionals}`;
136136
if (skeletonFileExists) {
137137
finalFileString = finalFileString.replace('{{ARGUMENTS}}', argumentsString);
138138
} else {
@@ -144,7 +144,7 @@ const createCommandFile = async (nestedCategory,docs) => {
144144
if (docs.options) {
145145
let optionsString = '';
146146
_.forEach(docs.options, (options, group) => {
147-
optionsString = `### ${group}\n\nOption | Default | Description\n--------- | ----------- | -----------\n${options}` + optionsString;
147+
optionsString = `### ${group}\n\nOption | Alias | Default | Description\n--------- | --------- | ----------- | -----------\n${options}` + optionsString;
148148
});
149149
if (skeletonFileExists) {
150150
finalFileString = finalFileString.replace('{{OPTIONS}}', optionsString);

lib/interface/cli/Command.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,16 @@ class Command {
228228
});
229229
description += choicesString;
230230
}
231+
let aliases = '';
232+
if (option.value.alias) {
233+
let aliasString = '';
234+
_.forEach(option.value.alias, (alias) => {
235+
aliasString += `- ${alias}`;
236+
});
237+
aliases += aliasString;
238+
}
231239
const defaultValue = option.value.default || '';
232-
res.options[group] += `--${key} | ${defaultValue} | ${description}\n`;
240+
res.options[group] += `--${key} | ${aliases} | ${defaultValue} | ${description}\n`;
233241
});
234242

235243
res.examples = '';

0 commit comments

Comments
 (0)