@@ -17,89 +17,87 @@ var input = [],
17
17
18
18
var args = process . argv . slice ( 2 ) ;
19
19
20
- if ( args . length ) {
20
+ var currentArg ;
21
21
22
- while ( args . length && ! args [ 0 ] . match ( / ^ \- / ) ) {
22
+ while ( args . length ) {
23
23
24
- input . push ( args . shift ( ) ) ;
24
+ currentArg = args . shift ( ) ;
25
25
26
- }
26
+ if ( / ^ (? ! \- ) . * / . test ( currentArg ) ) {
27
27
28
- } else {
28
+ input . push ( currentArg ) ;
29
29
30
- input = process . cwd ( ) ;
30
+ } else {
31
31
32
- }
32
+ switch ( currentArg ) {
33
33
34
- while ( args . length ) {
34
+ case '-t' :
35
+ case '--title' :
35
36
36
- switch ( args . shift ( ) ) {
37
+ config . title = args . shift ( ) ;
37
38
38
- case '-t' :
39
- case '--title' :
39
+ break ;
40
40
41
- config . title = args . shift ( ) ;
41
+ case '-d' :
42
+ case '--description' :
42
43
43
- break ;
44
+ config . description = args . shift ( ) ;
44
45
45
- case '-d' :
46
- case '--description' :
46
+ break ;
47
47
48
- config . description = args . shift ( ) ;
48
+ case '-l' :
49
+ case '--layout' :
49
50
50
- break ;
51
+ config . layout = args . shift ( ) ;
51
52
52
- case '-l' :
53
- case '--layout' :
53
+ break ;
54
54
55
- config . layout = args . shift ( ) ;
55
+ case '-o' :
56
+ case '--output' :
56
57
57
- break ;
58
+ output = args . shift ( ) ;
58
59
59
- case '-o' :
60
- case '--output' :
60
+ break ;
61
61
62
- output = args . shift ( ) ;
62
+ case '-p' :
63
+ case '--package' :
63
64
64
- break ;
65
+ pkg = args . shift ( ) ;
65
66
66
- case '-p' :
67
- case '--package' :
67
+ break ;
68
68
69
- pkg = args . shift ( ) ;
69
+ case '-v' :
70
+ case '--version' :
70
71
71
- break ;
72
+ process . stdout . write ( require ( '../package' ) . version + '\n' ) ;
73
+ process . exit ( ) ;
72
74
73
- case '-v' :
74
- case '--version' :
75
+ break ;
75
76
76
- process . stdout . write ( require ( '../package' ) . version + '\n' ) ;
77
- process . exit ( ) ;
77
+ default :
78
78
79
- break ;
79
+ process . stdout . write ( '\n' ) ;
80
+ process . stdout . write ( chalk . blue ( ' Usage:' ) + ' doxdox <path> [options]' + '\n\n' ) ;
81
+ process . stdout . write ( ' Options:' + '\n\n' ) ;
82
+ process . stdout . write ( chalk . yellow ( ' -h, --help' ) + '\t\t\tDisplay this help message.' + '\n' ) ;
83
+ process . stdout . write ( chalk . yellow ( ' -v, --version' ) + '\t\t\tDisplay the current installed version.' + '\n' ) ;
84
+ process . stdout . write ( chalk . yellow ( ' -t, --title' ) + '\t\t\tSets title.' + '\n' ) ;
85
+ process . stdout . write ( chalk . yellow ( ' -d, --description' ) + '\t\tSets description.' + '\n' ) ;
86
+ process . stdout . write ( chalk . yellow ( ' -l, --layout' ) + '\t\t\tTemplate to render the documentation with.' + '\n' ) ;
87
+ process . stdout . write ( chalk . yellow ( ' -p, --package' ) + '\t\t\tSets location of package.json file.' + '\n' ) ;
88
+ process . stdout . write ( chalk . yellow ( ' -o, --output' ) + '\t\t\tFile to save documentation to. Defaults to stdout.' + '\n' ) ;
89
+ process . stdout . write ( '\n' ) ;
90
+ process . stdout . write ( ' Available Layouts:' + '\n\n' ) ;
91
+ process . stdout . write ( ' - Bootstrap (default)\t\t(http://getbootstrap.com/)' + '\n' ) ;
92
+ process . stdout . write ( ' - Markdown\t\t\t(http://daringfireball.net/projects/markdown/)' + '\n' ) ;
93
+ process . stdout . write ( ' - Dash\t\t\t(http://kapeli.com/docsets/)' + '\n' ) ;
94
+ process . stdout . write ( ' - Wiki\t\t\t(https://help.github.com/articles/about-github-wikis/)' + '\n' ) ;
95
+ process . stdout . write ( '\n' ) ;
96
+ process . exit ( ) ;
80
97
81
- default :
98
+ break ;
82
99
83
- process . stdout . write ( '\n' ) ;
84
- process . stdout . write ( chalk . blue ( ' Usage:' ) + ' doxdox <path> [options]' + '\n\n' ) ;
85
- process . stdout . write ( ' Options:' + '\n\n' ) ;
86
- process . stdout . write ( chalk . yellow ( ' -h, --help' ) + '\t\t\tDisplay this help message.' + '\n' ) ;
87
- process . stdout . write ( chalk . yellow ( ' -v, --version' ) + '\t\t\tDisplay the current installed version.' + '\n' ) ;
88
- process . stdout . write ( chalk . yellow ( ' -t, --title' ) + '\t\t\tSets title.' + '\n' ) ;
89
- process . stdout . write ( chalk . yellow ( ' -d, --description' ) + '\t\tSets description.' + '\n' ) ;
90
- process . stdout . write ( chalk . yellow ( ' -l, --layout' ) + '\t\t\tTemplate to render the documentation with.' + '\n' ) ;
91
- process . stdout . write ( chalk . yellow ( ' -p, --package' ) + '\t\t\tSets location of package.json file.' + '\n' ) ;
92
- process . stdout . write ( chalk . yellow ( ' -o, --output' ) + '\t\t\tFile to save documentation to. Defaults to stdout.' + '\n' ) ;
93
- process . stdout . write ( '\n' ) ;
94
- process . stdout . write ( ' Available Layouts:' + '\n\n' ) ;
95
- process . stdout . write ( ' - Bootstrap (default)\t\t(http://getbootstrap.com/)' + '\n' ) ;
96
- process . stdout . write ( ' - Markdown\t\t\t(http://daringfireball.net/projects/markdown/)' + '\n' ) ;
97
- process . stdout . write ( ' - Dash\t\t\t(http://kapeli.com/docsets/)' + '\n' ) ;
98
- process . stdout . write ( ' - Wiki\t\t\t(https://help.github.com/articles/about-github-wikis/)' + '\n' ) ;
99
- process . stdout . write ( '\n' ) ;
100
- process . exit ( ) ;
101
-
102
- break ;
100
+ }
103
101
104
102
}
105
103
@@ -139,6 +137,12 @@ if (!config.title) {
139
137
140
138
}
141
139
140
+ if ( ! input . length ) {
141
+
142
+ input = process . cwd ( ) ;
143
+
144
+ }
145
+
142
146
doxdox . parseInput ( input , config , pkg ) . then ( function ( content ) {
143
147
144
148
if ( output ) {
0 commit comments