MCPcopy Index your code
hub / github.com/clearloop/leetcode-cli / run

Method run

src/cmd/data.rs:20–65  ·  view source on GitHub ↗

`data` handler

(&self)

Source from the content-addressed store, hash-verified

18impl DataArgs {
19 /// `data` handler
20 pub async fn run(&self) -> Result<(), Error> {
21 use std::fs::File;
22 use std::path::Path;
23
24 let cache = Cache::new()?;
25 let path = cache.0.conf.storage.cache()?;
26 let f = File::open(&path)?;
27 let len = format!("{}K", f.metadata()?.len() / 1000);
28
29 let out = format!(
30 " {}{}",
31 Path::new(&path)
32 .file_name()
33 .ok_or(Error::NoneError)?
34 .to_string_lossy()
35 .to_string()
36 .digit(65 - (len.len() as i32))
37 .bright_green(),
38 len
39 );
40
41 let mut title = "\n Cache".digit(63);
42 title.push_str("Size");
43 title.push_str("\n ");
44 title.push_str(&"-".repeat(65));
45
46 let mut flags = 0;
47 if self.delete {
48 flags += 1;
49 cache.clean()?;
50 println!("{}", "ok!".bright_green());
51 }
52
53 if self.update {
54 flags += 1;
55 cache.update().await?;
56 println!("{}", "ok!".bright_green());
57 }
58
59 if flags == 0 {
60 println!("{}", title.bright_black());
61 println!("{}\n", out);
62 }
63
64 Ok(())
65 }
66}

Callers

nothing calls this directly

Calls 4

cacheMethod · 0.80
digitMethod · 0.80
cleanMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected