khard icon indicating copy to clipboard operation
khard copied to clipboard

Stop asking for confirmation when non-interactive `modify`

Open DamienCassou opened this issue 6 years ago • 6 comments

Would it be possible to get rid of the confirmation question when stdin is used as input for modify? When used in a program, it is impossible to pass both the yaml content and the answer to the question through stdin.

$ khard modify --uid 8a < /tmp/damien.yaml
[…]
Do you want to proceed (y/n)?

Expected: no question because I already use stdin to pass the contact, I can't use it to also answer the question.

DamienCassou avatar Sep 28 '18 04:09 DamienCassou

If I understand the code in khard/khard.py line 1790-1803 correctly we reopen the terminal device to read the answer from the user after reading the input. Does it not work for you?

lucc avatar Dec 27 '18 13:12 lucc

Does it not work for you?

I don't know how to do that, not even if it is possible.

DamienCassou avatar Dec 28 '18 11:12 DamienCassou

For me it works.

~% khard ls -a dropin 
Address book: dropin
Index    Name            Phone    E-Mail    UID   
1        von Bar, Foo                       t     
~% khard modify  -a dropin --uid=t < foo 
Modification

Name: Foo hans von Bar
Address book: dropin
Miscellaneous
    UID: t9bo8ud06exx18qnar01kdkhhvb1mcrel7tl

Do you want to proceed (y/n)? y
Done
~% khard ls -a dropin                  
Address book: dropin
Index    Name                 Phone    E-Mail    UID   
1        von Bar, Foo hans                       t     

After reading the file from stdin the terminal device is opened again and connected to stdin.

lucc avatar Dec 28 '18 12:12 lucc

Non the less your feature request is interesting and can be discussed.

lucc avatar Dec 28 '18 12:12 lucc

Sorry, I wasn't clear enough. I don't know how to confirm using stdin when calling khard from a program.

DamienCassou avatar Dec 28 '18 12:12 DamienCassou

I think you can open a pull request with a new option --assume-yes or --no-confirm or so. Many package managers have that.

lucc avatar Dec 28 '18 18:12 lucc