cage icon indicating copy to clipboard operation
cage copied to clipboard

Better format for `cage source ls`

Open erithmetic opened this issue 9 years ago • 9 comments

I've found that the display format of the old cage source ls was difficult to grok at a glance.

Here's a new, one-row-per-service format:

caladan:rails_hello dkastner$ cargo run source ls
  SERVICE        IMAGE                 STATUS      LOCAL   REMOTE
  coffee-rails                         unmounted           https://github.com/rails/coffee-rails.git
  rails_hello    faraday/rails_hello   unmounted           https://github.com/faradayio/rails_hello.git
caladan:rails_hello dkastner$ cargo run source clone coffee-rails
Cloning into '/Users/dkastner/cage/examples/rails_hello/src/coffee-rails'...
caladan:rails_hello dkastner$ cargo run source ls
  SERVICE        IMAGE                 STATUS      LOCAL              REMOTE
  coffee-rails                         mounted     src/coffee-rails   https://github.com/rails/coffee-rails.git
  rails_hello    faraday/rails_hello   unmounted                      https://github.com/faradayio/rails_hello.git

erithmetic avatar Dec 12 '16 05:12 erithmetic

...aaaand looks like I need to fix the mount check :(

erithmetic avatar Dec 12 '16 05:12 erithmetic

OK, fixed mounted check

erithmetic avatar Dec 12 '16 05:12 erithmetic

@dkastner what did the old format look like for comparison?

seamusabshere avatar Dec 12 '16 13:12 seamusabshere

@seamusabshere

dkastner@arrakis:~/cage/examples/rails_hello$ cage source ls
coffee-rails              https://github.com/rails/coffee-rails.git
  Available at src/coffee-rails (mounted)
rails_hello               https://github.com/faradayio/rails_hello.git

The "mounted" note is hard to see at a glance. Also, the multiline format makes it hard to grep

erithmetic avatar Dec 12 '16 14:12 erithmetic

this looks great to me!

seamusabshere avatar Dec 12 '16 15:12 seamusabshere

I'm not a huge fan of massive, multi-column tables that wrap on 80-character terminals. Can we think of any alternate ways to present this information? I'd be OK with two formats, one for writing to TTYs and one for writing to pipes, or a JSON format that could be passed to jq.

emk avatar Dec 13 '16 19:12 emk

This is the same kind of format docker ps uses

erithmetic avatar Dec 13 '16 21:12 erithmetic

@dkastner The fact that Docker displays tables that don't respect terminal width limits the way regular ps does is my single least favorite thing about Docker. 🙁 I would love to find something better.

emk avatar Dec 14 '16 10:12 emk

I spoke with @dkastner about this again today, and I'm still leaning against supporting >80 char table output.

Instead, it might be possible to do something like the following:

sudo npm install -g json2csv
cargo install xsv

...and adding a --json flag to cage, allowing:

cage source ls --json | json2csv -f name,mounted | xsv table

(Optionally, jq could be used for more complicated filtering and transforms.)

However, this raises a related workflow issue, which is that we need some super-easy way to list just the mounted sources. I'd also be happy to support:

# One of the following?
cage source ls --mounted
cage source mounted

...or any reasonable variation on that theme.

emk avatar Sep 26 '17 14:09 emk