@@ -4,124 +4,157 @@ pub mod utils;
44
55use crate :: cli:: { Arg , Cli , Command } ;
66use crate :: commands:: all:: all_command;
7+ use crate :: commands:: followers:: followers_command;
78use crate :: commands:: releases:: releases_command;
89use crate :: commands:: user:: user_command;
910use crate :: utils:: { install, validate_and_convert_path, OS } ;
1011
1112fn main ( ) {
1213 let cli = Cli :: new ( ) . with_default_command ( "help" ) . with_commands ( vec ! [
13- Command :: new( "version" , "Displays the current version of github-stats. " ) . with_short( 'v' ) ,
14- Command :: new( "install" , "Installs the files and directories. " ) ,
15- Command :: new( "all" , "Gives all stats found on a repository as json. " )
14+ Command :: new( "version" , "Displays the current version of github-stats" ) . with_short( 'v' ) ,
15+ Command :: new( "install" , "Installs the files and directories" ) ,
16+ Command :: new( "all" , "Gives all stats found on a repository as json" )
1617 . with_arg(
1718 Arg :: new( )
1819 . with_name( "user" )
1920 . with_short( 'u' )
2021 . with_long( "user" )
2122 . with_value_name( "USER" )
22- . with_help( "The user who owns the repository. " ) ,
23+ . with_help( "The user who owns the repository" ) ,
2324 )
2425 . with_arg(
2526 Arg :: new( )
2627 . with_name( "repository" )
2728 . with_short( 'r' )
2829 . with_long( "repository" )
2930 . with_value_name( "REPOSITORY" )
30- . with_help( "Name of the repository. " ) ,
31+ . with_help( "Name of the repository" ) ,
3132 )
3233 . with_arg(
3334 Arg :: new( )
3435 . with_name( "output" )
3536 . with_short( 'o' )
3637 . with_long( "output" )
3738 . with_value_name( "OUTPUT" )
38- . with_help( "File path to save the json. " ) ,
39+ . with_help( "File path to save the json" ) ,
3940 )
4041 . with_arg(
4142 Arg :: new( )
4243 . with_name( "display" )
4344 . with_short( 'd' )
4445 . with_long( "display" )
45- . with_help( "Converts the json to an easier format (will remove some data). " ) ,
46+ . with_help( "Converts the json to an easier format (will remove some data)" ) ,
4647 ) ,
47- Command :: new( "releases" , "Gives information on github releases. " )
48+ Command :: new( "releases" , "Gives information on github releases" )
4849 . with_arg(
4950 Arg :: new( )
5051 . with_name( "user" )
5152 . with_short( 'u' )
5253 . with_long( "user" )
5354 . with_value_name( "USER" )
54- . with_help( "The user who owns the repository. " ) ,
55+ . with_help( "The user who owns the repository" ) ,
5556 )
5657 . with_arg(
5758 Arg :: new( )
5859 . with_name( "repository" )
5960 . with_short( 'r' )
6061 . with_long( "repository" )
6162 . with_value_name( "REPOSITORY" )
62- . with_help( "Name of the repository. " ) ,
63+ . with_help( "Name of the repository" ) ,
6364 )
6465 . with_arg(
6566 Arg :: new( )
6667 . with_name( "individual" )
6768 . with_short( 'i' )
6869 . with_long( "individual" )
69- . with_help( "Downloads per release. " ) ,
70+ . with_help( "Downloads per release" ) ,
7071 )
7172 . with_arg(
7273 Arg :: new( )
7374 . with_name( "link" )
7475 . with_short( 'l' )
7576 . with_long( "link" )
76- . with_help( "Download links for releases (if not individual then for latest). " ) ,
77+ . with_help( "Download links for releases (if not individual then for latest)" ) ,
7778 )
7879 . with_arg(
7980 Arg :: new( )
8081 . with_name( "output" )
8182 . with_short( 'o' )
8283 . with_long( "output" )
8384 . with_value_name( "OUTPUT" )
84- . with_help( "File path to save the json. " ) ,
85+ . with_help( "File path to save the json" ) ,
8586 )
8687 . with_arg(
8788 Arg :: new( )
8889 . with_name( "all" )
8990 . with_short( 'a' )
9091 . with_long( "all" )
91- . with_help( "All json from request. " ) ,
92+ . with_help( "All json from request" ) ,
9293 )
9394 . with_arg(
9495 Arg :: new( )
9596 . with_name( "display" )
9697 . with_short( 'd' )
9798 . with_long( "display" )
98- . with_help( "Converts the json to an easier format (will remove some data). " ) ,
99+ . with_help( "Converts the json to an easier format (will remove some data)" ) ,
99100 ) ,
100- Command :: new( "user" , "Gives information about a github user. " )
101+ Command :: new( "user" , "Gives information about a github user" )
101102 . with_arg(
102103 Arg :: new( )
103104 . with_name( "user" )
104105 . with_short( 'u' )
105106 . with_long( "user" )
106107 . with_value_name( "USER" )
107- . with_help( "The user you want information on. " ) ,
108+ . with_help( "The user you want information on" ) ,
108109 )
109110 . with_arg(
110111 Arg :: new( )
111112 . with_name( "output" )
112113 . with_short( 'o' )
113114 . with_long( "output" )
114115 . with_value_name( "OUTPUT" )
115- . with_help( "File path to save the json. " ) ,
116+ . with_help( "File path to save the json" ) ,
116117 )
117118 . with_arg(
118119 Arg :: new( )
119120 . with_name( "display" )
120121 . with_short( 'd' )
121122 . with_long( "display" )
122- . with_help( "Converts the json to an easier format (will remove some data). " ) ,
123+ . with_help( "Converts the json to an easier format (will remove some data)" ) ,
123124 ) ,
124- Command :: new( "help" , "Helps you with the commands." ) . with_short( 'h' ) ,
125+ Command :: new( "followers" , "Lists the followers of a github user" )
126+ . with_arg(
127+ Arg :: new( )
128+ . with_name( "user" )
129+ . with_short( 'u' )
130+ . with_long( "user" )
131+ . with_value_name( "USER" )
132+ . with_help( "The user you want information on" ) ,
133+ )
134+ . with_arg(
135+ Arg :: new( )
136+ . with_name( "total" )
137+ . with_short( 't' )
138+ . with_long( "total" )
139+ . with_value_name( "TOTAL" )
140+ . with_help( "Only gives the follower count" ) ,
141+ )
142+ . with_arg(
143+ Arg :: new( )
144+ . with_name( "output" )
145+ . with_short( 'o' )
146+ . with_long( "output" )
147+ . with_value_name( "OUTPUT" )
148+ . with_help( "File path to save the json" ) ,
149+ )
150+ . with_arg(
151+ Arg :: new( )
152+ . with_name( "display" )
153+ . with_short( 'd' )
154+ . with_long( "display" )
155+ . with_help( "Converts the json to an easier format (will remove some data)" ) ,
156+ ) ,
157+ Command :: new( "help" , "Helps you with the commands" ) . with_short( 'h' ) ,
125158 ] ) ;
126159
127160 let command = cli. match_commands ( ) ;
@@ -169,6 +202,16 @@ fn main() {
169202
170203 user_command ( user, output, display) ;
171204 }
205+ "followers" => {
206+ let user = command. get_value_of ( "user" ) . throw_if_none ( ) ;
207+ let total = command. has ( "total" ) ;
208+ let output = command. get_value_of ( "output" ) . to_option ( ) ;
209+ let display = command. has ( "display" ) ;
210+
211+ let output = output_to_path ( output) ;
212+
213+ followers_command ( user, total, output, display) ;
214+ }
172215 "help" => cli. help ( ) ,
173216 _ => cli. help ( ) ,
174217 }
0 commit comments