@@ -10,36 +10,36 @@ var argv = require('minimist')(process.argv.slice(2), {
10
10
g : 'groups' ,
11
11
h : 'help'
12
12
} ,
13
- boolean : [ 'e' , 'd' , 'm' , 'g' ]
13
+ boolean : [ 'e' , 'd' , 'm' , 'g' , 'h' ]
14
14
} ) ;
15
15
16
- console . log ( argv ) ;
17
-
18
16
if ( argv . h ) {
19
17
console . error (
20
- "Usage: " + process . argv [ 1 ] + " <doi> \n\
21
- Options: \n\
22
- -e, --exact Find an exact match \n\
23
- -d, --declared Find a DOI with a 'doi:' prefix\n\
24
- -m, --match Find all matches within the given string" ) ;
18
+ "Usage: " + process . argv [ 1 ] + " <doi>\n" +
19
+ " Options: \n" +
20
+ " -e, --exact Find an exact match \n" +
21
+ " -d, --declared Find a DOI with a 'doi:' prefix\n" +
22
+ " -m, --match Find all matches within the given string") ;
25
23
process . exit ( - 1 )
26
24
}
27
25
28
26
var doi = ( argv . doi || argv . _ [ 0 ] )
29
27
30
28
if ( argv . m ) {
31
29
console . log ( doi . match ( doiRegex ( ) ) )
30
+ process . exit ( - 1 )
32
31
} else if ( argv . g ) {
33
32
console . log ( doiRegex . groups ( doi ) ) ;
33
+ process . exit ( - 1 )
34
+ }
35
+
36
+ if ( argv . e && argv . d ) {
37
+ console . log ( 'Is this a declared DOI' ,
38
+ doiRegex . declared ( { exact : true } ) . test ( doi ) )
39
+ } else if ( argv . e && ! argv . d ) {
40
+ console . log ( 'Is this a DOI?' , doiRegex ( { exact : true } ) . test ( doi ) )
41
+ } else if ( ! argv . e && argv . d ) {
42
+ console . log ( 'Is the DOI declared?' , doiRegex . declared ( ) . test ( doi ) )
34
43
} else {
35
- if ( argv . e && argv . d ) {
36
- console . log ( 'Is this a declared DOI' ,
37
- doiRegex . declared ( { exact : true } ) . test ( doi ) )
38
- } else if ( argv . e && ! argv . d ) {
39
- console . log ( 'Is this a DOI?' , doiRegex ( { exact : true } ) . test ( doi ) )
40
- } else if ( ! argv . e && argv . d ) {
41
- console . log ( 'Is the DOI declared?' , doiRegex . declared ( ) . test ( doi ) )
42
- } else {
43
- console . log ( 'Does a DOI exist?' , doiRegex ( ) . test ( doi ) )
44
- }
44
+ console . log ( 'Does a DOI exist?' , doiRegex ( ) . test ( doi ) )
45
45
}
0 commit comments