Skip to content

Commit abf3b92

Browse files
Add types for the options in the docs. Replaced -d option with -v opt… (#684)
* Add types for the options in the docs. Replaced -d option with -v option in 'wait' command. * wip
1 parent bc75e0e commit abf3b92

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

docs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ const createCommandFile = async (nestedCategory,command) => {
184184
if (docs.options) {
185185
let optionsString = '';
186186
_.forEach(docs.options, (options, group) => {
187-
optionsString = `### ${group}\n\nOption | Alias | Default | Description\n--------- | --------- | ----------- | -----------\n${options}` + optionsString;
187+
optionsString = `### ${group}\n\nOption | Alias | Type | Default | Description\n--------- | --------- | --------- |----------- | -----------\n${options}` + optionsString;
188188
});
189189
if (skeletonFileExists) {
190190
finalFileString = finalFileString.replace('{{OPTIONS}}', optionsString);

lib/interface/cli/Command.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ class Command {
227227

228228
res.options = _.get(parentCommandDocs, 'options', {});
229229
_.forEach(options, (option) => {
230+
if (option.value.omitFromDocs) {
231+
return;
232+
}
230233
const group = option.value.group || 'Options';
231234
res.options[group] = res.options[group] || '';
232235
const key = option.key;
@@ -241,6 +244,24 @@ class Command {
241244
});
242245
description += choicesString;
243246
}
247+
248+
let optionType = '';
249+
if (option.value.type) {
250+
if (typeof option.value.type === 'string') {
251+
optionType = option.value.type;
252+
} else if (option.value.type === Array) {
253+
optionType = 'array';
254+
}
255+
} else if (option.value.default) {
256+
const primitiveTypes = ['string', 'number', 'boolean'];
257+
const defaultValueType = typeof option.value.default;
258+
if (primitiveTypes.includes(defaultValueType)) {
259+
optionType = defaultValueType;
260+
} else if (Array.isArray(option.value.default)) {
261+
optionType = 'array';
262+
}
263+
}
264+
244265
let aliases = '';
245266
if (option.value.alias) {
246267
if (_.size(option.value.alias) === 1) {
@@ -249,8 +270,8 @@ class Command {
249270
aliases += `--${option.value.alias}`;
250271
}
251272
}
252-
const defaultValue = option.value.default || '';
253-
res.options[group] += `--${key} | ${aliases} | ${defaultValue} | ${description}\n`;
273+
const defaultValue = option.value.default || (optionType === 'boolean' ? 'false' : '');
274+
res.options[group] += `--${key} | ${aliases} | ${optionType} | ${defaultValue} | ${description}\n`;
254275
});
255276

256277
res.examples = '';

lib/interface/cli/commands/hybrid/init.cmd.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,10 @@ const initCmd = new Command({
225225
default: false,
226226
type: 'boolean',
227227
})
228-
.example('codefresh runner init --values values.yaml (see values file example here: '
229-
+ 'https://github.com/codefresh-io/venona/blob/release-1.0/venonactl/example/values-example.yaml)'),
228+
.example(
229+
'codefresh runner init --values values.yaml',
230+
'See values file example here: https://github.com/codefresh-io/venona/blob/release-1.0/venonactl/example/values-example.yaml)',
231+
),
230232
handler: async (argv) => {
231233
let resumedInstallation = false;
232234

lib/interface/cli/commands/workflow/wait.cmd.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { sdk } = require('../../../../logic');
77
const Promise = require('bluebird');
88

99

10-
const annotate = new Command({
10+
const wait = new Command({
1111
root: true,
1212
command: 'wait <id..>',
1313
description: 'Wait until a condition will be met on a build',
@@ -26,9 +26,16 @@ const annotate = new Command({
2626
default: 'success',
2727
required: true,
2828
})
29+
.option('verbose', {
30+
alias: 'v',
31+
describe: 'Show debug output until the condition will be met.',
32+
default: false,
33+
type: 'boolean',
34+
})
2935
.option('debug', {
3036
alias: 'd',
31-
describe: 'Show debug output until the condition will be met',
37+
describe: 'Show debug output until the condition will be met.',
38+
omitFromDocs: true,
3239
})
3340
.option('timeout', {
3441
alias: 't',
@@ -45,7 +52,7 @@ const annotate = new Command({
4552
handler: async (argv) => {
4653
const workflowIds = argv.id;
4754
const desiredStatus = argv.status;
48-
const descriptive = argv.d;
55+
const descriptive = argv.d || argv.v;
4956

5057
_.forEach(workflowIds, (workflowId) => {
5158
if (!ObjectID.isValid(workflowId)) {
@@ -67,4 +74,4 @@ const annotate = new Command({
6774
},
6875
});
6976

70-
module.exports = annotate;
77+
module.exports = wait;

0 commit comments

Comments
 (0)