Closed pigmonkey closed 11 years ago
Yeah, ls
is definitely in need of some more customisability in the long term.
In general, I'm aiming to make the ppl CLI experience be as similar as possible to Git's, so that people familiar with Git can have lots of "Oh, that's easy, it's just like Git" moments instead of lots of learning.
One of the things you can do in ~/.gitconfig
is this:
[pretty]
my_favourite_format = "%h%x09%an%x09%ad%x09%s"
Another Git convention that ppl has followed so far is in generally not allowing you to customise the output or behaviour of stock commands except by the use of aliases. I think Git does this so that people can't accidentally break its core functionality or render it unusable for scripts. Stack Overflow is teeming with people asking how to change the default format of git log
, for example, and the answer is pretty much "You can't, so use an alias instead".
I'm only really mentioning that because I like to be explicit about when I'm breaking with convention, though. I'm not sure I think Git's strictness about such things is suitable here. I'm definitely open to allowing the format of ppl ls
to be configurable. So how about this?
[ls]
default_format = my_favourite_format
[pretty]
my_favourite_format = "%h%x09%an%x09%ad%x09%s"
another_format = "%u%an"
$ ppl ls
[output in "my_favourite_format"]
$ ppl ls --pretty=another_format
[output in "another_format"]
$ ppl ls --pretty=format:"%an%ad"
[output in format given as argument]
That would work fine for me. It's important to me to be able to configure it on the fly, not just in the config, but you've handled that with the --pretty=format:"..."
option.
I also wouldn't have a problem with keeping the ls
default format non-configurable and just using an alias, if you wanted to go that route.
Right then, I've put together a bit of an early release of some of this functionality. I was going to hold off until this was completely done, but it'll be weeks until I'm done tinkering and the core stuff is already there.
So there's a --format
option in ppl ls
now, and it accepts the following placeholders.
%n Newline
%i Contact ID
%N Name
%a Age
%b Birthday
%k Nickname (first)
%e Email address (preferred/first)
%p Phone number (preferred/first)
%o Organization (first)
If you want to store a particular format in your config file, it's just like configuring git.
[pretty]
age_info = "%i: %a (%b)"
And then invoke that with ppl ls --pretty=age_info
.
Like I said, this is a bit of an early release, so while it should be bug-free, it's incomplete. It'll take a while propagating this functionality to the rest of ppl's output. I've added some --format
options to ppl email
but eventually I want to add it to everything.
I'm open to suggestions in terms of adding extra placeholders, by the way.
I think it would be neat if I could customize the fields that are displayed in the output of
ppl ls
. I ran into a scenario yesterday where this would have been useful.For example, let's say I'm just interested in names and phone numbers. I could do something like this:
Or if I wanted to get all email addresses for contacts that belong to the organization "family", I could use this feature combined with
grep
.It'd also be cool if I could set the default
ls
fields in~/.pplconfig
.