From dfae48736ffd3504598b15e0f350269a8d1b1063 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 23 Jan 2012 20:23:31 -0600 Subject: [PATCH 1/3] Steps towards package descriptions. I added a description field for `package` objects (it's read from a literal string for now) and `print_pkg` now prints descriptions if they're there. --- src/cargo/cargo.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index a12c01de547..2edd205b783 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -34,6 +34,7 @@ type package = { uuid: str, url: str, method: str, + description: str, ref: option::t, tags: [str] }; @@ -269,12 +270,15 @@ fn load_one_source_package(&src: source, p: map::hashmap) { } _ { } } + // TODO: make this *actually* get the description from the .rc file. + let description = "This package's description."; vec::grow(src.packages, 1u, { // source: _source(src), name: name, uuid: uuid, url: url, method: method, + description: description, ref: ref, tags: tags }); @@ -681,6 +685,9 @@ fn print_pkg(s: source, p: package) { m = m + " [" + str::connect(p.tags, ", ") + "]"; } info(m); + if p.description != "" { + print(" >> " + p.description) + } } fn cmd_list(c: cargo, argv: [str]) { for_each_package(c, { |s, p| From 65840f3625482e2b8a860fce0c7c4da2669a9e22 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 23 Jan 2012 21:42:29 -0600 Subject: [PATCH 2/3] Get `description` attribute for packages from json. --- src/cargo/cargo.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 2edd205b783..27471cb1eaa 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -270,8 +270,15 @@ fn load_one_source_package(&src: source, p: map::hashmap) { } _ { } } - // TODO: make this *actually* get the description from the .rc file. - let description = "This package's description."; + + let description = alt p.find("description") { + some(json::string(_n)) { _n } + _ { + warn("Malformed source json: " + src.name + " (missing description)"); + ret; + } + }; + vec::grow(src.packages, 1u, { // source: _source(src), name: name, From 2c3cd1749e14682658ae3a958bb92404f795d263 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 23 Jan 2012 21:50:32 -0600 Subject: [PATCH 3/3] Added a newline after each description. `<@graydon> maybe an extra newline to make the grouping clearer?` --- src/cargo/cargo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cargo/cargo.rs b/src/cargo/cargo.rs index 27471cb1eaa..7d667dafdea 100644 --- a/src/cargo/cargo.rs +++ b/src/cargo/cargo.rs @@ -693,7 +693,7 @@ fn print_pkg(s: source, p: package) { } info(m); if p.description != "" { - print(" >> " + p.description) + print(" >> " + p.description + "\n") } } fn cmd_list(c: cargo, argv: [str]) {