@@ -21,7 +21,7 @@ use error::CliError;
21
21
pub type CliResult < T > = Result < T , CliError > ;
22
22
const CLOG_CONFIG_FILE : & ' static str = ".clog.toml" ;
23
23
24
- fn main ( ) {
24
+ fn main ( ) {
25
25
let styles = LinkStyle :: variants ( ) ;
26
26
let matches = App :: new ( "clog" )
27
27
// Pull version from Cargo.toml
@@ -107,32 +107,36 @@ project directory (i.e. /myproject/.clog.toml) you do not need to use --work-tre
107
107
pub fn from_matches ( matches : & ArgMatches ) -> CliResult < Clog > {
108
108
debugln ! ( "Creating clog from matches" ) ;
109
109
let mut clog = if let Some ( cfg) = matches. value_of ( "config" ) {
110
- debugln ! ( "User passed in config file: {:?}" , cfg) ;
110
+ debugln ! ( "User passed in config file: {:?}" , cfg) ;
111
111
if matches. is_present ( "workdir" ) && matches. is_present ( "gitdir" ) {
112
- debugln ! ( "User passed in both\n \t working dir: {:?}\n \t git dir: {:?}" , matches. value_of( "workdir" ) , matches. value_of( "gitdir" ) ) ;
112
+ debugln ! ( "User passed in both\n \t working dir: {:?}\n \t git dir: {:?}" ,
113
+ matches. value_of( "workdir" ) ,
114
+ matches. value_of( "gitdir" ) ) ;
113
115
// use --config --work-tree --git-dir
114
- try!( Clog :: with_all ( matches. value_of ( "gitdir" ) . unwrap ( ) ,
115
- matches. value_of ( "workdir" ) . unwrap ( ) ,
116
- cfg) )
116
+ try!( Clog :: with_all ( matches. value_of ( "gitdir" ) . unwrap ( ) ,
117
+ matches. value_of ( "workdir" ) . unwrap ( ) ,
118
+ cfg) )
117
119
} else if let Some ( dir) = matches. value_of ( "workdir" ) {
118
120
debugln ! ( "User passed in working dir: {:?}" , dir) ;
119
121
// use --config --work-tree
120
- try!( Clog :: with_dir_and_file ( dir, cfg) )
122
+ try!( Clog :: with_dir_and_file ( dir, cfg) )
121
123
} else if let Some ( dir) = matches. value_of ( "gitdir" ) {
122
124
debugln ! ( "User passed in git dir: {:?}" , dir) ;
123
125
// use --config --git-dir
124
- try!( Clog :: with_dir_and_file ( dir, cfg) )
126
+ try!( Clog :: with_dir_and_file ( dir, cfg) )
125
127
} else {
126
128
debugln ! ( "User only passed config" ) ;
127
129
// use --config only
128
- try!( Clog :: from_file ( cfg) )
130
+ try!( Clog :: from_file ( cfg) )
129
131
}
130
132
} else {
131
133
debugln ! ( "User didn't pass in a config" ) ;
132
134
if matches. is_present ( "gitdir" ) && matches. is_present ( "workdir" ) {
133
135
let wdir = matches. value_of ( "workdir" ) . unwrap ( ) ;
134
136
let gdir = matches. value_of ( "gitdir" ) . unwrap ( ) ;
135
- debugln ! ( "User passed in both\n \t working dir: {:?}\n \t git dir: {:?}" , wdir, gdir) ;
137
+ debugln ! ( "User passed in both\n \t working dir: {:?}\n \t git dir: {:?}" ,
138
+ wdir,
139
+ gdir) ;
136
140
try!( Clog :: with_dirs ( gdir, wdir) )
137
141
} else if let Some ( dir) = matches. value_of ( "gitdir" ) {
138
142
debugln ! ( "User passed in git dir: {:?}" , dir) ;
@@ -149,7 +153,9 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
149
153
// compute version early, so we can exit on error
150
154
clog. version = {
151
155
// less typing later...
152
- let ( major, minor, patch) = ( matches. is_present ( "major" ) , matches. is_present ( "minor" ) , matches. is_present ( "patch" ) ) ;
156
+ let ( major, minor, patch) = ( matches. is_present ( "major" ) ,
157
+ matches. is_present ( "minor" ) ,
158
+ matches. is_present ( "patch" ) ) ;
153
159
if matches. is_present ( "ver" ) {
154
160
matches. value_of ( "ver" ) . unwrap ( ) . to_owned ( )
155
161
} else if major || minor || patch {
@@ -166,15 +172,34 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
166
172
Ok ( ref mut v) => {
167
173
// if-else may be quicker, but it's longer mentally, and this isn't slow
168
174
match ( major, minor, patch) {
169
- ( true , _, _) => { v. major += 1 ; v. minor = 0 ; v. patch = 0 ; } ,
170
- ( _, true , _) => { v. minor += 1 ; v. patch = 0 ; } ,
171
- ( _, _, true ) => { v. patch += 1 ; clog. patch_ver = true ; } ,
172
- _ => unreachable ! ( )
175
+ ( true , _, _) => {
176
+ v. major += 1 ;
177
+ v. minor = 0 ;
178
+ v. patch = 0 ;
179
+ }
180
+ ( _, true , _) => {
181
+ v. minor += 1 ;
182
+ v. patch = 0 ;
183
+ }
184
+ ( _, _, true ) => {
185
+ v. patch += 1 ;
186
+ clog. patch_ver = true ;
187
+ }
188
+ _ => unreachable ! ( ) ,
173
189
}
174
- format ! ( "{}{}" , if had_v{ "v" } else{ "" } , v)
175
- } ,
190
+ format ! ( "{}{}" ,
191
+ if had_v {
192
+ "v"
193
+ } else {
194
+ ""
195
+ } ,
196
+ v)
197
+ }
176
198
Err ( e) => {
177
- return Err ( CliError :: Semver ( Box :: new ( e) , String :: from ( "Failed to parse version into valid SemVer. Ensure the version is in the X.Y.Z format." ) ) ) ;
199
+ return Err ( CliError :: Semver ( Box :: new ( e) ,
200
+ String :: from ( "Failed to parse version into \
201
+ valid SemVer. Ensure the version \
202
+ is in the X.Y.Z format.") ) ) ;
178
203
}
179
204
}
180
205
} else {
@@ -193,7 +218,8 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
193
218
}
194
219
195
220
if matches. is_present ( "link-style" ) {
196
- clog. link_style = value_t ! ( matches. value_of( "link-style" ) , LinkStyle ) . unwrap_or ( LinkStyle :: Github ) ;
221
+ clog. link_style = value_t ! ( matches. value_of( "link-style" ) , LinkStyle )
222
+ . unwrap_or ( LinkStyle :: Github ) ;
197
223
}
198
224
199
225
if let Some ( subtitle) = matches. value_of ( "subtitle" ) {
0 commit comments