diff --git a/Cargo.lock b/Cargo.lock index 8471faca1..4db4681d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,18 @@ dependencies = [ "winapi", ] +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "assert_cmd" version = "1.0.1" @@ -83,6 +95,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + [[package]] name = "bit-set" version = "0.5.2" @@ -104,6 +122,29 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +[[package]] +name = "blake2b_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "bstr" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "byteorder" version = "1.3.4" @@ -166,18 +207,74 @@ dependencies = [ "bitflags", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg 1.0.1", + "cfg-if 0.1.10", + "lazy_static", +] + +[[package]] +name = "csv" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc4666154fd004af3fd6f1da2e81a96fd5a81927fe8ddb6ecc79e2aa6e138b54" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + [[package]] name = "difference" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" +[[package]] +name = "dirs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "doc-comment" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "failure" version = "0.1.8" @@ -389,6 +486,20 @@ dependencies = [ "treeline", ] +[[package]] +name = "prettytable-rs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e" +dependencies = [ + "atty", + "csv", + "encode_unicode", + "lazy_static", + "term", + "unicode-width", +] + [[package]] name = "proc-macro2" version = "1.0.24" @@ -608,6 +719,17 @@ version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +[[package]] +name = "redox_users" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" +dependencies = [ + "getrandom", + "redox_syscall", + "rust-argon2", +] + [[package]] name = "regex" version = "1.4.2" @@ -620,6 +742,15 @@ dependencies = [ "thread_local", ] +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", +] + [[package]] name = "regex-syntax" version = "0.6.21" @@ -656,6 +787,18 @@ dependencies = [ "serde", ] +[[package]] +name = "rust-argon2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +dependencies = [ + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + [[package]] name = "rustc-demangle" version = "0.1.18" @@ -767,6 +910,7 @@ dependencies = [ "clap", "failure", "predicates", + "prettytable-rs", "taskchampion", "uuid", ] @@ -795,6 +939,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "term" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +dependencies = [ + "byteorder", + "dirs", + "winapi", +] + [[package]] name = "textwrap" version = "0.11.0" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 75ba8be47..c5bf41c85 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -9,6 +9,7 @@ clap = "~2.33.0" uuid = { version = "0.8.1", features = ["serde", "v4"] } taskchampion = { path = "../taskchampion" } failure = "0.1.8" +prettytable-rs = "0.8.0" [dev-dependencies] assert_cmd = "1.0.1" diff --git a/cli/src/cmd/list.rs b/cli/src/cmd/list.rs index fb02e4645..2d51484e9 100644 --- a/cli/src/cmd/list.rs +++ b/cli/src/cmd/list.rs @@ -1,5 +1,7 @@ +use crate::table; use clap::{App, ArgMatches, SubCommand as ClapSubCommand}; use failure::Fallible; +use prettytable::{cell, row, Table}; use crate::cmd::{ArgMatchResult, CommandInvocation}; @@ -21,9 +23,13 @@ define_subcommand! { subcommand_invocation! { fn run(&self, command: &CommandInvocation) -> Fallible<()> { + let mut t = Table::new(); + t.set_format(table::format()); + t.set_titles(row![b->"uuid", b->"description"]); for (uuid, task) in command.get_replica().all_tasks().unwrap() { - println!("{} - {:?}", uuid, task); + t.add_row(row![uuid, task.get_description()]); } + t.printstd(); Ok(()) } } diff --git a/cli/src/cmd/pending.rs b/cli/src/cmd/pending.rs index e847a4aef..8fbca52d9 100644 --- a/cli/src/cmd/pending.rs +++ b/cli/src/cmd/pending.rs @@ -1,5 +1,7 @@ +use crate::table; use clap::{App, ArgMatches, SubCommand as ClapSubCommand}; use failure::Fallible; +use prettytable::{cell, row, Table}; use crate::cmd::{ArgMatchResult, CommandInvocation}; @@ -24,11 +26,15 @@ define_subcommand! { subcommand_invocation! { fn run(&self, command: &CommandInvocation) -> Fallible<()> { let working_set = command.get_replica().working_set().unwrap(); + let mut t = Table::new(); + t.set_format(table::format()); + t.set_titles(row![b->"id", b->"description"]); for i in 1..working_set.len() { if let Some(ref task) = working_set[i] { - println!("{}: {} - {:?}", i, task.get_uuid(), task); + t.add_row(row![i, task.get_description()]); } } + t.printstd(); Ok(()) } } diff --git a/cli/src/lib.rs b/cli/src/lib.rs index af5aed9a7..a71670ac1 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -3,6 +3,8 @@ use failure::Fallible; use std::ffi::OsString; mod cmd; +mod table; + use cmd::ArgMatchResult; pub use cmd::CommandInvocation; diff --git a/cli/src/table.rs b/cli/src/table.rs new file mode 100644 index 000000000..9fdb9b833 --- /dev/null +++ b/cli/src/table.rs @@ -0,0 +1,8 @@ +use prettytable::format; + +pub(crate) fn format() -> format::TableFormat { + format::FormatBuilder::new() + .column_separator(' ') + .borders(' ') + .build() +}