Skip to content

Commit daf0212

Browse files
author
Schmidely Stéphane
committed
Add Export utils
1 parent 238d729 commit daf0212

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

src/utils/commands/export/utils.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { EOL } from 'os'
2+
3+
export default class ExportUtils {
4+
constructor() {}
5+
6+
/**
7+
* CLI flags of 'export' commands
8+
* Filter 'help' command
9+
*/
10+
public availableFlags(flags: any) {
11+
return Object.keys(flags).filter((el, _index, _array) => {
12+
return el !== 'help'
13+
})
14+
}
15+
16+
/**
17+
* Format error message
18+
*/
19+
public errorMessage(singularTitle: string, errorList: Array<string>) {
20+
const plural = (errorList.length > 1) ? 's' : ''
21+
const title = `${singularTitle}${plural}`
22+
const details = errorList.map((error: string) => {
23+
return `• ${error}`
24+
}).join(EOL)
25+
return `${title}${EOL}${details}`
26+
}
27+
}

0 commit comments

Comments
 (0)