Repository: peterheesterman/chit (language: rust)

Issue:
(feat) What other crates did this person write? 
## What do you think needs adding and why?

I think a chit should be able to tell me what else this person owns in the rust eco system so that i can understand more about them as a person


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d968517..0241357 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
 
 # Change Log
 
+## 0.0.3 - Add other crates of owner
+ - Change the order thing apear in the chit
+ - Add details of the other crates of an owner
+ - better padded write abstraction
+ - update readme with an image
+
 ## 0.0.2 - Getting better
  - A change log
  - Better visuals 
diff --git a/Cargo.lock b/Cargo.lock
index 7270c06..45863b8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -68,7 +68,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "chit"
-version = "0.0.2"
+version = "0.0.3"
 dependencies = [
  "colored 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "reqwest 0.9.12 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 4da75ba..a3f28f6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "chit"
-version = "0.0.2"
+version = "0.0.3"
 authors = ["Peter Heesterman <heesterman.peter@gmail.com>"]
 edition = "2018"
 
diff --git a/README.md b/README.md
index 5c6494e..f48a0ce 100644
--- a/README.md
+++ b/README.md
@@ -2,12 +2,13 @@
 
 A tool for looking up details about crates without going to crates.io
 
-chit serde
+`chit serde`
 
-The informatoin it should show me
+![Chit]( https://github.com/peterheesterman/chit/blob/master/readme-images/chit.png?raw=true "Chit")
+
+The informatoin it should show me in the future
 ```
-  // Who is the owner?
-  // What versions are there? When did they some out?
+  // What versions are there? When did they come out?
   // What are the downloads over time?
   // Should i use this crate? 
   // How mature is it? <Star rating>
diff --git a/readme-images/chit.png b/readme-images/chit.png
new file mode 100644
index 0000000..25184d7
Binary files /dev/null and b/readme-images/chit.png differ
diff --git a/research/crates_of_user.json b/research/crates_of_user.json
new file mode 100644
index 0000000..d6dde58
--- /dev/null
+++ b/research/crates_of_user.json
@@ -0,0 +1,181 @@
+{
+  "crates": [{
+    "id": "chit",
+    "name": "chit",
+    "updated_at": "2019-03-24T04:24:34.120232+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2019-03-21T05:09:55.767680+00:00",
+    "downloads": 24,
+    "recent_downloads": 24,
+    "max_version": "0.0.2",
+    "description": "A tool for looking up details about crates without going to crates.io",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/chit",
+    "links": {
+      "version_downloads": "/api/v1/crates/chit/downloads",
+      "versions": "/api/v1/crates/chit/versions",
+      "owners": "/api/v1/crates/chit/owners",
+      "owner_team": "/api/v1/crates/chit/owner_team",
+      "owner_user": "/api/v1/crates/chit/owner_user",
+      "reverse_dependencies": "/api/v1/crates/chit/reverse_dependencies"
+    },
+    "exact_match": false
+  }, {
+    "id": "lsb_png_steganography",
+    "name": "lsb_png_steganography",
+    "updated_at": "2018-10-21T21:21:42.742758+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2018-10-21T21:21:42.742758+00:00",
+    "downloads": 78,
+    "recent_downloads": 22,
+    "max_version": "0.1.0",
+    "description": "Least significant bit portable network graphic steganography",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/lsb_png_steganography",
+    "links": {
+      "version_downloads": "/api/v1/crates/lsb_png_steganography/downloads",
+      "versions": "/api/v1/crates/lsb_png_steganography/versions",
+      "owners": "/api/v1/crates/lsb_png_steganography/owners",
+      "owner_team": "/api/v1/crates/lsb_png_steganography/owner_team",
+      "owner_user": "/api/v1/crates/lsb_png_steganography/owner_user",
+      "reverse_dependencies": "/api/v1/crates/lsb_png_steganography/reverse_dependencies"
+    },
+    "exact_match": false
+  }, {
+    "id": "lsb_text_png_steganography",
+    "name": "lsb_text_png_steganography",
+    "updated_at": "2018-11-01T05:41:12.711151+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2018-10-27T20:40:53.411012+00:00",
+    "downloads": 160,
+    "recent_downloads": 35,
+    "max_version": "0.1.2",
+    "description": "A steganography strategy that uses the least significant bits of a png to hide text",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/lsb_text_png_steganography",
+    "links": {
+      "version_downloads": "/api/v1/crates/lsb_text_png_steganography/downloads",
+      "versions": "/api/v1/crates/lsb_text_png_steganography/versions",
+      "owners": "/api/v1/crates/lsb_text_png_steganography/owners",
+      "owner_team": "/api/v1/crates/lsb_text_png_steganography/owner_team",
+      "owner_user": "/api/v1/crates/lsb_text_png_steganography/owner_user",
+      "reverse_dependencies": "/api/v1/crates/lsb_text_png_steganography/reverse_dependencies"
+    },
+    "exact_match": false
+  }, {
+    "id": "ree",
+    "name": "ree",
+    "updated_at": "2019-03-16T17:31:59.567732+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2019-03-14T08:27:42.764994+00:00",
+    "downloads": 32,
+    "recent_downloads": 32,
+    "max_version": "0.0.2",
+    "description": "Prints out depth-indented listing of files in a folder",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/ree",
+    "links": {
+      "version_downloads": "/api/v1/crates/ree/downloads",
+      "versions": "/api/v1/crates/ree/versions",
+      "owners": "/api/v1/crates/ree/owners",
+      "owner_team": "/api/v1/crates/ree/owner_team",
+      "owner_user": "/api/v1/crates/ree/owner_user",
+      "reverse_dependencies": "/api/v1/crates/ree/reverse_dependencies"
+    },
+    "exact_match": false
+  }, {
+    "id": "steg",
+    "name": "steg",
+    "updated_at": "2018-11-01T05:34:49.325586+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2018-10-22T19:15:53.475385+00:00",
+    "downloads": 302,
+    "recent_downloads": 41,
+    "max_version": "0.1.5",
+    "description": "Command line steganography tool",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/lsb_png_steganography",
+    "links": {
+      "version_downloads": "/api/v1/crates/steg/downloads",
+      "versions": "/api/v1/crates/steg/versions",
+      "owners": "/api/v1/crates/steg/owners",
+      "owner_team": "/api/v1/crates/steg/owner_team",
+      "owner_user": "/api/v1/crates/steg/owner_user",
+      "reverse_dependencies": "/api/v1/crates/steg/reverse_dependencies"
+    },
+    "exact_match": false
+  }, {
+    "id": "stegray",
+    "name": "stegray",
+    "updated_at": "2018-11-03T06:13:11.825655+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2018-11-03T06:13:11.825655+00:00",
+    "downloads": 51,
+    "recent_downloads": 15,
+    "max_version": "0.0.1",
+    "description": "Data type for steg the command line steganography tool",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/stegray",
+    "links": {
+      "version_downloads": "/api/v1/crates/stegray/downloads",
+      "versions": "/api/v1/crates/stegray/versions",
+      "owners": "/api/v1/crates/stegray/owners",
+      "owner_team": "/api/v1/crates/stegray/owner_team",
+      "owner_user": "/api/v1/crates/stegray/owner_user",
+      "reverse_dependencies": "/api/v1/crates/stegray/reverse_dependencies"
+    },
+    "exact_match": false
+  }, {
+    "id": "whitespace_text_steganography",
+    "name": "whitespace_text_steganography",
+    "updated_at": "2018-10-29T05:17:50.707488+00:00",
+    "versions": null,
+    "keywords": null,
+    "categories": null,
+    "badges": [],
+    "created_at": "2018-10-23T08:21:29.714214+00:00",
+    "downloads": 330,
+    "recent_downloads": 44,
+    "max_version": "0.2.1",
+    "description": "A steganography strategy that uses whitespace to hide text in other text",
+    "homepage": null,
+    "documentation": null,
+    "repository": "https://github.com/peterheesterman/whitespace_text_steganography",
+    "links": {
+      "version_downloads": "/api/v1/crates/whitespace_text_steganography/downloads",
+      "versions": "/api/v1/crates/whitespace_text_steganography/versions",
+      "owners": "/api/v1/crates/whitespace_text_steganography/owners",
+      "owner_team": "/api/v1/crates/whitespace_text_steganography/owner_team",
+      "owner_user": "/api/v1/crates/whitespace_text_steganography/owner_user",
+      "reverse_dependencies": "/api/v1/crates/whitespace_text_steganography/reverse_dependencies"
+    },
+    "exact_match": false
+  }],
+  "meta": {
+    "total": 7
+  }
+}
\ No newline at end of file
diff --git a/research/research.md b/research/research.md
index 05997cf..771d161 100644
--- a/research/research.md
+++ b/research/research.md
@@ -2,4 +2,5 @@
 ## Endpoints
 
 - versions https://crates.io/api/v1/crates/[crate name]
-- owners https://crates.io/api/v1/crates/[crate name]/owners
\ No newline at end of file
+- owners https://crates.io/api/v1/crates/[crate name]/owners
+- crates_of_user https://crates.io/api/v1/crates?page=1&per_page=10&sort=alpha&user_id=28804
\ No newline at end of file
diff --git a/src/crates.rs b/src/crates.rs
index c63f5c4..977fc28 100644
--- a/src/crates.rs
+++ b/src/crates.rs
@@ -12,6 +12,11 @@ pub fn owners_url(crate_name: &str) -> String {
   format!("{}/{}/owners", ENDPOIONT, crate_name)
 }
 
+pub fn user_url(user_id: u64) -> String {
+  let per_page = 100;
+  format!("{}?page=1&per_page={}&sort=alpha&user_id={}", ENDPOIONT, per_page, user_id)
+}
+
 pub fn get(url: String) -> serde_json::value::Value {
     let mut res = reqwest::get(&url)
                     .expect("fail to get crate");
diff --git a/src/format.rs b/src/format.rs
index eb54ca7..10c8763 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -42,7 +42,7 @@ pub fn end_bar(width: usize) -> String {
 }
 
 pub fn get_width(crate_name: &str) -> usize {
-    let width = 40;
+    let width = 65;
     if crate_name.len() > width - 2 {
       10 + crate_name.len()
     } else {
diff --git a/src/main.rs b/src/main.rs
index 316cce7..64eaa9d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -21,6 +21,10 @@ fn main() {
     }
 }
 
+// This should use a closure
+fn padded_print(width: usize, message: String) {
+    println!("{}", format::pad(width, &message));
+}
 
 fn chit(crate_name: String) {
     let width = format::get_width(&crate_name);
@@ -28,37 +32,37 @@ fn chit(crate_name: String) {
 
     let crate_json: Value = crates::get(crates::url(&crate_name));
     let crate_owners_json: Value = crates::get(crates::owners_url(&crate_name));
-
-    // Owners
-    println!(
-        "{}",
-        format::pad(
-            width,
-            &format!(
-                "Current owner: {}",
-                crate_owners_json["users"][0]["name"].to_string()
-            )
-        )
-    );
-
+    
     // Version
-    println!(
-        "{}",
-        format::pad(
-            width,
-            &format!(
-                "Current version: {}",
-                crate_json["crate"]["max_version"].to_string()
-            )
-        )
-    );
+    padded_print(width, format!(
+        "Lastest version: {} ({})",
+        crate_json["crate"]["max_version"].to_string(),
+        crate_json["crate"]["updated_at"].to_string()
+    ));
 
     // Download count
     if let Some(download_count) = crate_json["crate"]["downloads"].as_i64() {
-        println!(
-            "{}",
-            format::pad(width, &format!("Download count: {:?}", download_count))
-        );
+        padded_print(width, format!("Download count: {:?}", download_count));
+    }
+
+    // Owners
+    padded_print(width, String::new());
+    padded_print(width, format!(
+        "Written by {}, Other crates by the same owner:",
+        crate_owners_json["users"][0]["name"].to_string()
+    ));
+
+    // Other crates
+    if let Some(user_id) = crate_owners_json["users"][0]["id"].as_u64() {
+        let user_json: Value = crates::get(crates::user_url(user_id));
+        if let Some(array) = user_json["crates"].as_array() {
+            for thing in array {
+                padded_print(width, format!(
+                    "    {}",
+                    thing["id"].to_string()
+                ));
+            }
+        }
     }
 
     println!("{}", format::end_bar(width));


Test patch: