Skip to content

Commit eba6192

Browse files
committed
fix clippy warnings + fmt
1 parent ef34912 commit eba6192

File tree

1 file changed

+20
-43
lines changed

1 file changed

+20
-43
lines changed

crates/cli/src/run.rs

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ pub async fn run(args: args::Args) -> Result<Option<FreezeSummary>, CollectError
1111
return handle_help_subcommands(args);
1212
}
1313

14-
let cryo_dir = build_cryo_directory(&args.output_dir.clone().into());
14+
let cryo_dir = build_cryo_directory(std::path::Path::new(&args.output_dir));
1515

16-
17-
let args = if args.datatype.is_empty() {
18-
load_or_remember_command(args, &cryo_dir)?
19-
} else {
20-
args
21-
};
16+
let args =
17+
if args.datatype.is_empty() { load_or_remember_command(args, &cryo_dir)? } else { args };
2218

2319
if args.remember {
2420
println!("remembering this command for future use\n");
@@ -35,16 +31,16 @@ fn is_help_command(args: &args::Args) -> bool {
3531
}
3632

3733
/// Build the cryo directory path.
38-
fn build_cryo_directory(output_dir: &std::path::PathBuf) -> std::path::PathBuf {
34+
fn build_cryo_directory(output_dir: &std::path::Path) -> std::path::PathBuf {
3935
output_dir.join(".cryo")
4036
}
4137

4238
/// Load a previously remembered command or return the current args.
4339
fn load_or_remember_command(
4440
mut args: args::Args,
45-
cryo_dir: &std::path::PathBuf,
41+
cryo_dir: &std::path::Path,
4642
) -> Result<args::Args, CollectError> {
47-
let remembered = remember::load_remembered_command(cryo_dir.clone())?;
43+
let remembered = remember::load_remembered_command(cryo_dir.to_path_buf())?;
4844
// Warn if the remembered command comes from a different Cryo version.
4945
if remembered.cryo_version != cryo_freeze::CRYO_VERSION {
5046
eprintln!("remembered command comes from a different Cryo version, proceed with caution\n");
@@ -54,35 +50,24 @@ fn load_or_remember_command(
5450
Ok(args)
5551
}
5652

57-
5853
/// Print the remembered command to the console.
5954
fn print_remembered_command(command: &[String]) {
6055
println!(
6156
"{} {} {}",
6257
"remembering previous command:".truecolor(170, 170, 170),
6358
"cryo".bold().white(),
64-
command
65-
.iter()
66-
.skip(1)
67-
.cloned()
68-
.collect::<Vec<_>>()
69-
.join(" ")
70-
.white()
71-
.bold()
59+
command.iter().skip(1).cloned().collect::<Vec<_>>().join(" ").white().bold()
7260
);
7361
println!();
7462
}
7563

7664
/// Run the main freezing process with the provided arguments.
77-
async fn run_freeze_process(
78-
args: args::Args,
79-
) -> Result<Option<FreezeSummary>, CollectError> {
65+
async fn run_freeze_process(args: args::Args) -> Result<Option<FreezeSummary>, CollectError> {
8066
let t_start_parse = Some(SystemTime::now());
8167
let (query, source, sink, env) = parse::parse_args(&args).await?;
8268

8369
let source = Arc::new(source);
84-
let env = ExecutionEnv {t_start_parse, ..env}
85-
.set_start_time();
70+
let env = ExecutionEnv { t_start_parse, ..env }.set_start_time();
8671

8772
cryo_freeze::freeze(&query, &source, &sink, &env).await
8873
}
@@ -109,8 +94,8 @@ fn print_general_help() {
10994

11095
/// Print syntax help for block and transaction specification.
11196
fn print_syntax_help() {
112-
let content = cstr!(
113-
r#"<white><bold>Block specification syntax</bold></white>
97+
let content = cstr!(
98+
r#"<white><bold>Block specification syntax</bold></white>
11499
- can use numbers <white><bold>--blocks 5000 6000 7000</bold></white>
115100
- can use ranges <white><bold>--blocks 12M:13M 15M:16M</bold></white>
116101
- can use a parquet file <white><bold>--blocks ./path/to/file.parquet[:COLUMN_NAME]</bold></white>
@@ -128,16 +113,13 @@ fn print_syntax_help() {
128113
- can use a parquet file <white><bold>--txs ./path/to/file.parquet[:COLUMN_NAME]</bold></white>
129114
(default column name is <white><bold>transaction_hash</bold></white>)
130115
- can use multiple parquet files <white><bold>--txs ./path/to/ethereum__logs*.parquet</bold></white>"#
131-
);
132-
println!("{}", content);
116+
);
117+
println!("{}", content);
133118
}
134119

135120
/// Handle detailed help by parsing schemas and printing dataset information.
136121
fn handle_detailed_help(args: args::Args) -> Result<(), CollectError> {
137-
let args = args::Args {
138-
datatype: args.datatype[1..].to_vec(),
139-
..args
140-
};
122+
let args = args::Args { datatype: args.datatype[1..].to_vec(), ..args };
141123
let (datatypes, schemas) = super::parse::schemas::parse_schemas(&args)?;
142124

143125
for datatype in datatypes.into_iter() {
@@ -159,24 +141,19 @@ mod tests {
159141
use super::*;
160142
use crate::args::Args;
161143

162-
#[test]
144+
#[test]
163145
fn test_handle_help_subcommands_general_help() {
164-
let args = Args {
165-
datatype: vec!["help".to_string()],
166-
..Default::default()
167-
};
146+
let args = Args { datatype: vec!["help".to_string()], ..Default::default() };
168147

169148
let result = handle_help_subcommands(args);
170149

171150
assert!(result.is_ok());
172151
}
173152

174-
#[test]
153+
#[test]
175154
fn test_handle_help_subcommands_syntax_help() {
176-
let args = Args {
177-
datatype: vec!["help".to_string(), "syntax".to_string()],
178-
..Default::default()
179-
};
155+
let args =
156+
Args { datatype: vec!["help".to_string(), "syntax".to_string()], ..Default::default() };
180157

181158
let result = handle_help_subcommands(args);
182159

@@ -194,4 +171,4 @@ mod tests {
194171

195172
assert!(result.is_ok());
196173
}
197-
}
174+
}

0 commit comments

Comments
 (0)