@@ -11,69 +11,75 @@ use controller::{Search, SearchTrait};
1111fn run ( ) {
1212 log:: info!( "Starting git2mail!" ) ;
1313
14- let argv: ArgMatches = Command :: new ( "git2mail" )
15- . author ( "exti0p ")
16- . about ( "Pure Rust OSINT tool to find a GitHub user's email ")
17- . arg (
18- Arg :: new ( "url" )
19- . short ( 'u' )
20- . long ( "url" )
21- . help ( "GitHub repository or profile URL you want to scan ")
22- . takes_value ( true ) ,
23- )
24- . arg (
25- Arg :: new ( "query" )
26- . short ( 'q' )
27- . long ( "query" )
28- . help ( "Query to find interesting GitHub repositories for you" )
29- . takes_value ( true ) ,
30- )
31- . arg (
32- Arg :: new ( "language" )
33- . short ( 'l' )
34- . long ( " language" )
35- . help ( "Select a language to enhance your repository searches" )
36- . takes_value ( true ) ,
37- )
38- . arg (
39- Arg :: new ( "limit ")
40- . long ( " limit" )
41- . default_value ( "5" )
42- . help ( "Defines the limit of scanned repositories" )
43- . takes_value ( true ) ,
44- )
45- . arg (
46- Arg :: new ( " token")
47- . short ( 't' )
48- . long ( "token" )
49- . help ( "Authenticate to the GitHub API with your GitHub token" )
50- . takes_value ( true ) ,
51- )
52- . arg (
53- Arg :: new ( "token-file" )
54- . long ( "token-file ")
55- . help (
56- "JSON file that contains your GitHub tokens to authenticate to the GitHub API" ,
57- )
58- . takes_value ( true ) ,
59- )
60- . get_matches ( ) ;
14+ let argv: ArgMatches =
15+ Command :: new ( "git2mail ")
16+ . author ( "exti0p ")
17+ . about ( "Pure Rust OSINT tool to find a GitHub user's email" )
18+ . arg (
19+ Arg :: new ( "url" )
20+ . short ( 'u' )
21+ . long ( "url ")
22+ . help ( "GitHub repository or profile URL you want to scan" ) ,
23+ )
24+ . arg (
25+ Arg :: new ( "query" )
26+ . short ( 'q' )
27+ . long ( "query" )
28+ . help ( "Query to find interesting GitHub repositories for you" ) ,
29+ )
30+ . arg (
31+ Arg :: new ( "language" )
32+ . short ( 'l' )
33+ . long ( "language" )
34+ . help ( "Select a language to enhance your repository searches" ) ,
35+ )
36+ . arg (
37+ Arg :: new ( "limit" )
38+ . long ( "limit" )
39+ . default_value ( "5 ")
40+ . help ( "Defines the limit of scanned repositories" ) ,
41+ )
42+ . arg (
43+ Arg :: new ( "token" )
44+ . short ( 't' )
45+ . long ( "token" )
46+ . help ( "Authenticate to the GitHub API with your GitHub token") ,
47+ )
48+ . arg ( Arg :: new ( "token-file" ) . long ( "token-file" ) . help (
49+ "JSON file that contains your GitHub tokens to authenticate to the GitHub API" ,
50+ ) )
51+ . get_matches ( ) ;
52+
53+ let url : String = argv
54+ . get_one :: < String > ( "url ")
55+ . unwrap_or ( & "" . to_string ( ) )
56+ . to_string ( ) ;
57+ let query : String = argv
58+ . get_one :: < String > ( "query" )
59+ . unwrap_or ( & "" . to_string ( ) )
60+ . to_string ( ) ;
6161
6262 let mut search = <Search as SearchTrait >:: new (
63- argv. value_of ( "url" ) . unwrap_or_default ( ) . to_string ( ) ,
64- argv. value_of ( "query" ) . unwrap_or_default ( ) . to_string ( ) ,
65- argv. value_of ( "language" ) . unwrap_or_default ( ) . to_string ( ) ,
66- argv. value_of ( "token" ) . unwrap_or_default ( ) . to_string ( ) ,
67- argv. value_of ( "token-file" ) . unwrap_or_default ( ) . to_string ( ) ,
68- argv. value_of ( "limit" )
69- . unwrap_or_default ( )
63+ url. clone ( ) ,
64+ query. clone ( ) ,
65+ argv. get_one :: < String > ( "language" )
66+ . unwrap_or ( & "" . to_string ( ) )
67+ . to_string ( ) ,
68+ argv. get_one :: < String > ( "token" )
69+ . unwrap_or ( & "" . to_string ( ) )
70+ . to_string ( ) ,
71+ argv. get_one :: < String > ( "token-file" )
72+ . unwrap_or ( & "" . to_string ( ) )
73+ . to_string ( ) ,
74+ argv. get_one :: < String > ( "limit" )
75+ . unwrap_or ( & "" . to_string ( ) )
7076 . parse :: < u8 > ( )
7177 . unwrap_or_default ( ) ,
7278 ) ;
7379
74- if argv . is_present ( "url" ) {
80+ if !url . is_empty ( ) {
7581 search. scan_target ( ) ;
76- } else if argv . is_present ( "query" ) {
82+ } else if !query . is_empty ( ) {
7783 search. aggregate_search ( ) ;
7884 }
7985}
0 commit comments