Repository navigation
Expand file tree
/
Copy pathDefaultCommand.ts
More file actions
63 lines (53 loc) · 1.69 KB
/
Copy pathDefaultCommand.ts
File metadata and controls
63 lines (53 loc) · 1.69 KB
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
61
62
63
import { CommandModule, Argv, Arguments } from 'yargs'
import { InfoCommand } from './InfoCommand'
import { ScanCommand } from './ScanCommand'
import { ConvertCommand } from './ConvertCommand'
import { DefaultOptions } from '../Options/DefaultOptions'
import { getAvailableCodecs, getAvailableEncoders, getAvailableFormats } from '../MediaFunctions'
import { WatchCommand } from './WatchCommand'
export class DefaultCommand implements CommandModule<{}, DefaultOptions> {
command = '$0 [command]'
builder = (args: Argv<{}>): Argv<DefaultOptions> => {
return args
.positional('command', {
choices: ['convert', 'info', 'scan'],
type: 'string',
})
.option('codecs', {
default: false,
type: 'boolean',
})
.option('encoders', {
default: false,
type: 'boolean',
})
.option('formats', {
default: false,
type: 'boolean',
})
.command(new ConvertCommand())
.command(new ScanCommand())
.command(new InfoCommand())
.command(new WatchCommand())
}
handler = async (args: Arguments<DefaultOptions>) => {
if (args.codecs) {
const codecs = await getAvailableCodecs()
Object.keys(codecs)
.sort()
.forEach((key) => console.log(key, codecs[key].description))
}
if (args.encoders) {
const encoders = await getAvailableEncoders()
Object.keys(encoders)
.sort()
.forEach((key) => console.log(key, encoders[key].description))
}
if (args.formats) {
const formats = await getAvailableFormats()
Object.keys(formats)
.sort()
.forEach((key) => console.log(key, formats[key].description))
}
}
}