File tree 2 files changed +15
-15
lines changed
2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ git2 = {version = "0.7.5", default-features = false}
13
13
tokei = " 8.0"
14
14
license = " 0.7.1"
15
15
bytecount = " 0.5.1"
16
+ clap = " 2.33.0"
Original file line number Diff line number Diff line change @@ -3,11 +3,14 @@ extern crate colored;
3
3
extern crate git2;
4
4
extern crate license;
5
5
extern crate tokei;
6
+ #[ macro_use]
7
+ extern crate clap;
6
8
7
9
use colored:: Color ;
8
10
use colored:: * ;
9
11
use git2:: Repository ;
10
12
use license:: License ;
13
+ use clap:: { App , Arg } ;
11
14
use std:: {
12
15
cmp,
13
16
collections:: HashMap ,
@@ -282,21 +285,17 @@ fn main() -> Result<()> {
282
285
return Err ( Error :: GitNotInstalled ) ;
283
286
}
284
287
285
- let mut args = env:: args ( ) ;
286
-
287
- if args. next ( ) . is_none ( ) {
288
- return Err ( Error :: TooFewArgs ) ;
289
- } ;
290
-
291
- let dir = if let Some ( arg) = args. next ( ) {
292
- arg
293
- } else {
294
- String :: from ( "." )
295
- } ;
296
-
297
- if args. next ( ) . is_some ( ) {
298
- return Err ( Error :: TooManyArgs ) ;
299
- } ;
288
+ let matches = App :: new ( crate_name ! ( ) )
289
+ . version ( crate_version ! ( ) )
290
+ . author ( crate_authors ! ( "\n " ) )
291
+ . about ( crate_description ! ( ) )
292
+ . arg ( Arg :: with_name ( "directory" )
293
+ . short ( "d" )
294
+ . long ( "dir" )
295
+ . takes_value ( true )
296
+ . default_value ( "." ) )
297
+ . get_matches ( ) ;
298
+ let dir = String :: from ( matches. value_of ( "directory" ) . unwrap ( ) ) ;
300
299
301
300
let tokei_langs = project_languages ( & dir) ;
302
301
let languages_stat = get_languages_stat ( & tokei_langs) . ok_or ( Error :: SourceCodeNotFound ) ?;
You can’t perform that action at this time.
0 commit comments