This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcli.js
executable file
·60 lines (54 loc) · 1.66 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
import meow from 'meow';
import wpPot from 'wp-pot';
const helpText = `
Usage
$ wp-pot <options>
Options
--bug-report -b Header with URL for reporting translation bugs
--comment-keyword -c Comment keyword
--dest-file -o Destination file
--domain -d Domain to retrieve the translated text
--last-translator -l Name and email address of the last translator (ex: John Doe <[email protected]>)
--relative-to -r Path to folder that file comments should be relative to
--src -s Source files
--team -t Name and email address of the translation team (ex: Team <[email protected]>)
--package -p Package name
--write-file -w Write file
--no-file-paths Don't write file paths to pot file
--no-write-file -w=false Don't write file
Examples
$ wp-pot --src 'src/*.php'
`;
const cli = meow(helpText, {
alias: {
b: 'bug-report',
c: 'comment-keyword',
d: 'domain',
l: 'last-translator',
o: 'dest-file',
r: 'relative-to',
s: 'src',
t: 'team',
p: 'package',
w: 'write-file'
},
default: {
writeFile: true,
filePaths: true
},
boolean: ['write-file', 'file-paths'],
src: {
isMultiple: true
},
importMeta: import.meta
});
if (cli.flags.filePaths === false) {
cli.flags.noFilePaths = !cli.flags.filePaths;
delete cli.flags.filePaths;
}
const content = wpPot(cli.flags);
// Output content if we shouldn't write a file.
if (!cli.flags.writeFile) {
process.stdout.write(content);
}