-
Notifications
You must be signed in to change notification settings - Fork 4
/
cli.js
executable file
·75 lines (69 loc) · 2 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
import ReleaseParser from './ReleaseParser.js'
import pckg from './package.json' assert { type: 'json' }
/**
* CLI interface for ReleaseParser
*
* @author Wellington Estevo
* @version 1.4.4
*/
// Skip first two args
// https://nodejs.org/en/knowledge/command-line/how-to-parse-command-line-arguments/
var releaseName = process.argv[2] !== '' ? process.argv[2] : ''
var section = process.argv[3] !== '' ? process.argv[3] : ''
// No release name given?
if ( typeof releaseName !== 'string' || releaseName === '' )
{
console.error( 'Please enter a proper release name.' )
}
else
{
// Check for commands or parse release
switch ( releaseName )
{
// Version
case '-v':
case '-version':
case '--version':
console.log( 'v' + pckg.version )
break
// Help
case '-h':
case '-help':
case '--help':
console.log([
"",
" " + pckg.description,
"",
" Example:",
" release-parser 24.S02E02.9.00.Uhr.bis.10.00.Uhr.German.DL.TV.Dubbed.DVDRip.SVCD.READ.NFO-c0nFuSed tv",
"",
" => {",
" release: '24.S02E02.9.00.Uhr.bis.10.00.Uhr.German.DL.TV.Dubbed.DVDRip.SVCD.READ.NFO-c0nFuSed',",
" title: '24',",
" titleExtra: '9 00 Uhr bis 10 00 Uhr',",
" group: 'c0nFuSed',",
" year: null,",
" date: null,",
" season: 2,",
" episode: 2,",
" flags: [ 'READNFO', 'TV Dubbed' ],",
" source: 'DVDRip',",
" format: 'SVCD',",
" resolution: null,",
" audio: null,",
" device: null,",
" version: null,",
" language: { de: 'German', multi: 'Multilingual' },",
" type: 'TV'",
" }",
"",
" If you get errors, try enclosing the release name in parenthesis: \"Artist--Title-(Bla)-2000-Group\"",
" Some shells have issues with some characters (like brackets)."
].join('\n'))
break
// Default parse
default:
console.log( ReleaseParser( releaseName, section ).data )
}
}