-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redesigning the command line interface #179
Comments
Then, an equivalent command to Another possible command line flag that could be useful in replacing those ls-like commands could be You use |
Actually, it seems the only thing
Allowing fields to be specified empowers the user to do their own processing. For example, if I wanted to count the number of people with each last name, I would just do
If I wanted to make a list of people by what state they live in
Or find the phone area codes used by region
You get the picture. The issue would be determining a good way to select fields. I suggest we do it similar to how the yaml file is spelled out, but
|
@earboxer the last time a though about it I sopped to persue the But I still like the |
Searching for contacts where some property is non empty This is mentioned as the I think this kind of functionallity should be represented in the custom query syntax mentioned in #131 as The main reason to push this into the query language and not have an option (or a modifier on the fields) is that it is a thing to select contacts not to select data to output. These are two things I would like to seperate in the user interface. |
I couldn't find a way to print out the value to terminal, for example Email field from a contact without the titles. which then can be copied to clipboard with piping to clipboard. I might be overlooking the fact that there might be multiple matches, which can just be fed to |
I have collected some thoughts and ideas about the command line interface of khard and how it could be improved. I will share them here and hope for people joining the discussion.
status quo
Currently we have 16 subcommands and some aliases. I would order them into these categories:
ls
,bdays
,email
,phone
,file
show
,export
edit
,source
merge
,copy
,move
,rm
,abooks
,new
,add-email
plan
I think the commands for the first three categories can be unified into three general commands with some new options (first the easy ones :)
edit
and it takes one new option--source
(and--yaml
or just--format={source,yaml}
) to provide the behaviour of the currentsource
command.show
command and introduce an option--format={pretty,yaml,vcard}
to provide the currentexport
functionality (and even a new one withvcard
: just print the contents of the vcard on stdout)--format
option.All old command names could be kept as a kind of compatibility alias for some time.
format option for new
ls
For compatibility the
--format
option could accept some special strings to mimic the exact behaviour of the old listing commands.I light of some open pull requests about special/new listing options for some subcommands (#175, #89) we could also accept python format strings that would be interpolated with the contact objects. Then people could write their own format strings. This would also open up khard for use in custom shell scripts (which is a thing that I also would like).
One problem with format strings is that I do not know how we can implement alignment over the whole printed list. We currently do that by generating a python
list
with strings for each entry and then search for the longest entry in each column to adjust the amount of whitespace. With plain format strings this is not possible. One would have to implement a special string at which to inject alignment (but that introduces string parsing and escaping issues into the new format strings) or we would have to support lists of format strings so that we can insert the alignment between them. Lastly we could ignore the alignment issue for custom, user written format strings and only support it in our buildin special format name (which are meant to mimic the format of our current subcommands).Another problem with custom format strings is that some attributes of the vcard objects are lists and we would have to decide if the format string is applied to the whole list or for each entry in turn. This corresponds to the problem in #173.
If I have enough time I will open PRs for the first to command unifications. For the listing commands I will wait for some comments first.
The text was updated successfully, but these errors were encountered: