Repository: peterheesterman/chit (language: rust)

Issue:
Licenses
**Is your feature request related to a problem? Please describe.**
I want to know what license the package i am looking at is released under.

**Describe the solution you'd like**
Another entry in the chit output and the versions output for license.



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c555fea..0234fbd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
 
 # Change Log
 
+## 0.1.5 - A license to ... show
+ - Include the software license for the shown crate
+
 ## 0.1.4 - A link to the ... docs
  - Add external resource links for docs, crates.io and repo (Thanks to lnicola for the suggestion!)
  - Fix border alignment is not an issue
diff --git a/Cargo.lock b/Cargo.lock
index 7eddf43..91d28a4 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -86,7 +86,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "chit"
-version = "0.1.4"
+version = "0.1.5"
 dependencies = [
  "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "colored 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 399e8dd..6ad22eb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "chit"
-version = "0.1.4"
+version = "0.1.5"
 authors = ["Peter Heesterman <heesterman.peter@gmail.com>"]
 edition = "2018"
 
diff --git a/README.md b/README.md
index bf9df23..335a320 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ If not... [find out how!](https://doc.rust-lang.org/cargo/getting-started/instal
 
 `chit hex-buffer-serde` OR `chit --crate=hex-buffer-serde`
 
-<img src="https://github.com/peterheesterman/chit/blob/master/readme-images/chit.png?raw=true" width="461"  height="203"/>
+<img src="https://github.com/peterheesterman/chit/blob/master/readme-images/chit.png?raw=true" width="461"  height="221"/>
 
 `chit versions --crate=hex-buffer-serde`
 
diff --git a/readme-images/chit.png b/readme-images/chit.png
index f7180fd..32d72f1 100644
Binary files a/readme-images/chit.png and b/readme-images/chit.png differ
diff --git a/readme-images/owners.png b/readme-images/owners.png
index 7709b47..981a097 100644
Binary files a/readme-images/owners.png and b/readme-images/owners.png differ
diff --git a/readme-images/versions.png b/readme-images/versions.png
index 6a17cc1..15e5e03 100644
Binary files a/readme-images/versions.png and b/readme-images/versions.png differ
diff --git a/src/extract.rs b/src/extract.rs
index 8f771aa..dccb759 100644
--- a/src/extract.rs
+++ b/src/extract.rs
@@ -4,6 +4,7 @@ pub struct Version {
     pub date: String,
     pub downloads: Option<i64>,
     pub size_in_bytes: Option<i64>,
+    pub license: String,
 }
 
 #[derive(Debug, Clone)]
@@ -34,6 +35,7 @@ pub fn crate_fields(json: serde_json::value::Value) -> Option<Crate> {
                     semver: version["num"].to_string(),
                     downloads: version["downloads"].as_i64(),
                     size_in_bytes: version["crate_size"].as_i64(),
+                    license: version["license"].to_string(),
                 };
             })
             .collect();
diff --git a/src/main.rs b/src/main.rs
index 06a3e2a..3737333 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ use clap::{App, Arg, SubCommand};
 use colored::*;
 use std::env;
 
+mod meta;
 mod crates;
 mod extract;
 mod format;
@@ -12,22 +13,20 @@ fn main() {
     let versions = "versions";
     let owners = "owners";
 
-    let reserved = vec![help, versions, owners, "-h", "--help", "-V", "--version"];
-
     // Keep it simple
     let args: Vec<String> = env::args().collect();
-
     if args.len() == 2 {
         let crate_name = args[1].clone();
+        let reserved = vec![help, versions, owners, "-h", "--help", "-V", "--version"];
         if !reserved.contains(&&crate_name.as_str()) {
             chit(crate_name.to_string());
             return;
         }
     }
 
-    // Next level
-    let semver = "0.1.4";
-    let author = "Peter Heesterman <heesterman.peter@gmail.com>";
+    // Meta
+    let semver = meta::get_version();
+    let author = meta::get_author();
 
     // Args
     let crate_arg_name = "crate";
@@ -137,6 +136,10 @@ fn chit(crate_name: String) {
                     format!("Crates.io: https://crates.io/crates/{}", &crate_name)
                 );
 
+                format::print(
+                    format!("License: {}", format::remove_quotes(recent_version.license))
+                );
+
                 if let Some(size) = recent_version.size_in_bytes {
                     format::print(format!("Crate size: {} kB", (size as f64 / 1000_f64).round()));
                 }
@@ -231,10 +234,11 @@ fn chit_versions(crate_name: String) {
                     if let Some(size) = version.size_in_bytes {
                         format::print(
                             format!(
-                                "    {} | {} | {} kB",
+                                "    {}  ({}) | {} | {} kB",
                                 format::remove_quotes(version.semver),
+                                format::remove_quotes(version.license),
                                 version.date,
-                                (size as f64 / 1000_f64).round()
+                                (size as f64 / 1000_f64).round(),
                             )
                         );
                     } else {
diff --git a/src/meta.rs b/src/meta.rs
new file mode 100644
index 0000000..75f6a1b
--- /dev/null
+++ b/src/meta.rs
@@ -0,0 +1,8 @@
+
+pub fn get_version() -> &'static str {
+	"0.1.5"
+}
+
+pub fn get_author() -> &'static str {
+	"Peter Heesterman <heesterman.peter@gmail.com>"
+}


Test patch: