Skip to content

Commit

Permalink
feat(addon): add a parser to check options format
Browse files Browse the repository at this point in the history
  • Loading branch information
davlgd committed Nov 26, 2024
1 parent 2ec8651 commit 081c23c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/clever.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ function run () {
}),
addonOptions: cliparse.option('option', {
metavar: 'option',
parser: Parsers.addonOptions,
description: 'Option to enable for the add-on. Multiple --option argument can be passed to enable multiple options',
}),
region: cliparse.option('region', {
Expand Down
11 changes: 11 additions & 0 deletions src/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import * as Application from './models/application.js';
import ISO8601 from 'iso8601-duration';
import Duration from 'duration-js';

const addonOptionsRegex = /^\w+=.+$/;

export function addonOptions (options) {
for (const option of options) {
if (!option.match(addonOptionsRegex)) {
return cliparse.parsers.error('Invalid option: ' + option);
}
}
return cliparse.parsers.success(options.join(','));
}

export function flavor (flavor) {
const flavors = Application.listAvailableFlavors();
if (flavors.includes(flavor)) {
Expand Down

0 comments on commit 081c23c

Please sign in to comment.