Skip to content

Commit 025239a

Browse files
committed
Merge pull request #75 from clog-tool/rustfmt
chore: reformat code using rustfmt
2 parents 99a06ed + 5227f73 commit 025239a

File tree

6 files changed

+63
-28
lines changed

6 files changed

+63
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515

1616
# Temporary files
1717
.*~
18+
19+
# Backup files
20+
*.bk

rustfmt.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn_brace_style = "PreferSameLine"
2+
struct_trailing_comma = "Never"
3+
struct_lit_trailing_comma = "Never"
4+
struct_lit_multiline_style = "ForceMulti"
5+
enum_trailing_comma = false

src/error.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,17 @@ impl Error for CliError {
4949
fn description<'a>(&'a self) -> &'a str {
5050
match *self {
5151
CliError::Semver(_, ref s) => &*s,
52-
CliError::Generic(ref d) => &*d,
53-
CliError::Unknown => "An unknown fatal error has occurred, please consider filing a bug-report!"
52+
CliError::Generic(ref d) => &*d,
53+
CliError::Unknown =>
54+
"An unknown fatal error has occurred, please consider filing a bug-report!",
5455
}
5556
}
5657

5758
fn cause(&self) -> Option<&Error> {
5859
match *self {
5960
CliError::Semver(ref e, _) => Some(&**e),
60-
CliError::Generic(..) => None,
61-
CliError::Unknown => None
61+
CliError::Generic(..) => None,
62+
CliError::Unknown => None,
6263
}
6364
}
6465
}
@@ -67,4 +68,4 @@ impl From<ClogErr> for CliError {
6768
fn from(ce: ClogErr) -> Self {
6869
CliError::Generic(ce.description().to_owned())
6970
}
70-
}
71+
}

src/fmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use ansi_term::ANSIString;
77

88
#[allow(dead_code)]
99
pub enum Format<T> {
10-
Error(T),
11-
Warning(T),
12-
Good(T),
10+
Error(T),
11+
Warning(T),
12+
Good(T)
1313
}
1414

1515
#[cfg(all(feature = "color", not(target_os = "windows")))]

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ macro_rules! debugln {
3535
macro_rules! debug {
3636
($fmt:expr) => ();
3737
($fmt:expr, $($arg:tt)*) => ();
38-
}
38+
}

src/main.rs

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use error::CliError;
2121
pub type CliResult<T> = Result<T, CliError>;
2222
const CLOG_CONFIG_FILE: &'static str = ".clog.toml";
2323

24-
fn main () {
24+
fn main() {
2525
let styles = LinkStyle::variants();
2626
let matches = App::new("clog")
2727
// Pull version from Cargo.toml
@@ -107,32 +107,36 @@ project directory (i.e. /myproject/.clog.toml) you do not need to use --work-tre
107107
pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
108108
debugln!("Creating clog from matches");
109109
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);
111111
if matches.is_present("workdir") && matches.is_present("gitdir") {
112-
debugln!("User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}", matches.value_of("workdir"), matches.value_of("gitdir"));
112+
debugln!("User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}",
113+
matches.value_of("workdir"),
114+
matches.value_of("gitdir"));
113115
// 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))
117119
} else if let Some(dir) = matches.value_of("workdir") {
118120
debugln!("User passed in working dir: {:?}", dir);
119121
// use --config --work-tree
120-
try!(Clog::with_dir_and_file(dir, cfg))
122+
try!(Clog::with_dir_and_file(dir, cfg))
121123
} else if let Some(dir) = matches.value_of("gitdir") {
122124
debugln!("User passed in git dir: {:?}", dir);
123125
// use --config --git-dir
124-
try!(Clog::with_dir_and_file(dir, cfg))
126+
try!(Clog::with_dir_and_file(dir, cfg))
125127
} else {
126128
debugln!("User only passed config");
127129
// use --config only
128-
try!(Clog::from_file(cfg))
130+
try!(Clog::from_file(cfg))
129131
}
130132
} else {
131133
debugln!("User didn't pass in a config");
132134
if matches.is_present("gitdir") && matches.is_present("workdir") {
133135
let wdir = matches.value_of("workdir").unwrap();
134136
let gdir = matches.value_of("gitdir").unwrap();
135-
debugln!("User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}", wdir, gdir);
137+
debugln!("User passed in both\n\tworking dir: {:?}\n\tgit dir: {:?}",
138+
wdir,
139+
gdir);
136140
try!(Clog::with_dirs(gdir, wdir))
137141
} else if let Some(dir) = matches.value_of("gitdir") {
138142
debugln!("User passed in git dir: {:?}", dir);
@@ -149,7 +153,9 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
149153
// compute version early, so we can exit on error
150154
clog.version = {
151155
// 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"));
153159
if matches.is_present("ver") {
154160
matches.value_of("ver").unwrap().to_owned()
155161
} else if major || minor || patch {
@@ -166,15 +172,34 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
166172
Ok(ref mut v) => {
167173
// if-else may be quicker, but it's longer mentally, and this isn't slow
168174
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!(),
173189
}
174-
format!("{}{}", if had_v{"v"}else{""}, v)
175-
},
190+
format!("{}{}",
191+
if had_v {
192+
"v"
193+
} else {
194+
""
195+
},
196+
v)
197+
}
176198
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.")));
178203
}
179204
}
180205
} else {
@@ -193,7 +218,8 @@ pub fn from_matches(matches: &ArgMatches) -> CliResult<Clog> {
193218
}
194219

195220
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);
197223
}
198224

199225
if let Some(subtitle) = matches.value_of("subtitle") {

0 commit comments

Comments
 (0)