summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-06 01:34:54 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-06 19:56:12 -0700
commit735fd480e43d6037f3ae7890c2795fdf0e431fd7 (patch)
tree5c6992780a8cced58d4dac2775002df2416955c1 /src/main.rs
parentefb2e0908b7f71a3f6ee6678c423c72b105f99ab (diff)
Improve alignment when printing sites
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index d5568cf..e9f0d99 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -17,8 +17,17 @@ fn main() {
}
if opts.list_sites {
- for s in ls.sites() {
- println!("{}: {}", s.api_site_parameter, s.site_url);
+ let sites = ls.sites();
+ match sites.into_iter().map(|s| s.api_site_parameter.len()).max() {
+ Some(max_w) => {
+ for s in ls.sites() {
+ println!("{:>w$}: {}", s.api_site_parameter, s.site_url, w = max_w);
+ }
+ }
+ None => {
+ // TODO stderr
+ println!("The site list is empty. Try running `so --update-sites`.");
+ }
}
return;
}