Skip to content
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

New feature request : --force flag #368

Closed
leongm opened this issue Mar 19, 2019 · 6 comments
Closed

New feature request : --force flag #368

leongm opened this issue Mar 19, 2019 · 6 comments

Comments

@leongm
Copy link

leongm commented Mar 19, 2019

Hi
buku is a great piece of job. I would like to use it for bookmark backup, syncing, im/export and manipulation (eg tag filtering). However, some buku operations (eg -d --ai etc) expect user interaction (typically y/n answer) and calling buku from a bash script to automate bookmark manipulation seems problematic. I wasnt able to find a suitable buku option that prevents this behavior. My attempts to bypass the buku prompt are based on the suggestions I found there https://askubuntu.com/questions/338857/automatically-enter-input-in-command-line and there
https://likegeeks.com/expect-command/. None of them was successful.
Is there any way to include some sort of --force flag or some other options that would allow buku to perform bookmark management without the user interaction or with default answer ?
I'm not a coder in any way and I am sorry I cannot develop myself such a feature to be ported to buku

@jarun
Copy link
Owner

jarun commented Mar 19, 2019

To some extent you can do that using the option --tacit.

@leongm
Copy link
Author

leongm commented Mar 19, 2019

Thank you for your answer. But still not the solution
buku --tacit -d prompts the user and buku --tacit --ai does not allow me to answer 'no' to chromium bookmark import and 'yes' to firefox bookmarks

@jarun
Copy link
Owner

jarun commented Mar 19, 2019

-d is completely destructive and the prompt was added based on an issue. It's much safer that way.

buku --tacit --ai is a one-time command. I don't see the issue.

@leongm
Copy link
Author

leongm commented Mar 20, 2019

about -d : yes it drops the database but it is no more destructive than usual commands such as rm. The latter defaults as an interactive command prompting the user to confirm the action ; but it has a --force flag allowing the user to bypass confirmation. buku -d could have the same behavior. Moreover, as buku imports bookmarks that are otherwise stored in various browser databases, bookmarks can still be recovered with buku --ai in case of unwanted buku -d --force

buku --tacit --ai is a one-time command. I don't see the issue

Assume that I want to import only firefox boorkmarks (not chromium). How can I do this with buku --tacit --ai?

Anyway, I managed to find a solution to my issue based on expect. I use the following script to first backup and then drop the current buku database and create and populate a new buku db with firefox bookmarks

I excecute the following script

#!/bin/sh

BINDIR=$HOME/bin
cp $HOME/.local/share/buku/bookmarks.db $HOME/.local/share/buku/bookmarks_$(date +%Y_%m_%d_%H_%M_%S).db
rm -f $HOME/.local/share/buku/bookmarks.db
exec $BINDIR/bukuexpect.sh

that calls bukuexpect.sh

#!/usr/bin/expect -f
##  bukuexpect.sh : automatic answers to buku --ai prompts

spawn buku -d
expect "Remove ALL bookmarks? (y/n):"
send "y\r"
spawn buku --ai
expect "Add parent folder names as tags? (y/n):"
send "y\r"
expect "Import bookmarks from google chrome? (y/n):"
send "n\r"
expect "Import bookmarks from chromium? (y/n):"
send "n\r"
expect "Import bookmarks from Firefox? (y/n):"
send "y\r"
expect eof

Thanks for your help. And again : buku is great :)

@jarun
Copy link
Owner

jarun commented Mar 20, 2019

This is a great solution! I will add it to the wiki.

@jarun jarun closed this as completed in 11ded13 Mar 20, 2019
@jarun
Copy link
Owner

jarun commented Mar 20, 2019

Added to the readme for other users. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants