Skip to content

Commit 6161526

Browse files
committed
finished implementing display options on downloads command
1 parent e9cb967 commit 6161526

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/commands/downloads.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ pub fn downloads_command(
117117
std::process::exit(0)
118118
}
119119

120+
let simple_data = simplify_json_release_data(&json);
121+
120122
if all && !display {
121123
println!("{:#?}", json);
122124
} else if all && display {
123-
let simple_data = simplify_json_release_data(&json);
124125
let mut download_count = 0;
125126
for release in simple_data {
126127
release.display();
@@ -130,6 +131,22 @@ pub fn downloads_command(
130131
} else if !all && !display {
131132
// if individual, get latest download url, and sum all item count
132133
// {download_url: Vec<(String name, String link for each asset of latest)>, html_url: String, download_count: i32}
134+
} else if !all && display {
135+
let mut download_count = 0;
136+
for release in &simple_data {
137+
download_count += release.downloads;
138+
if individual {
139+
print!("{} - {}", release.downloads, release.created_at);
140+
if link {
141+
print!(" - {}", release.html_url);
142+
}
143+
println!()
144+
}
145+
}
146+
println!("Total Downloads: {}", download_count);
147+
if link {
148+
println!("Latest Release: {}", simple_data[0].html_url)
149+
}
133150
}
134151

135152
match output {

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::commands::downloads::downloads_command;
88
use crate::utils::validate_and_convert_path;
99

1010
fn main() {
11+
//TODO: command to show info about a user
1112
let cli = Cli::new().with_default_command("help").with_commands(vec![
1213
Command::new("version", "Displays the current version of github-stats").with_short('v'),
1314
Command::new("install", "Installs the files and directories"),

0 commit comments

Comments
 (0)