mirror of
https://github.com/go-shiori/shiori.git
synced 2025-01-16 12:57:58 +08:00
Confirm to user for batch updating archive
This commit is contained in:
parent
dd4c10732a
commit
89cc8caa23
1 changed files with 17 additions and 0 deletions
|
@ -41,6 +41,7 @@ func updateCmd() *cobra.Command {
|
|||
cmd.Flags().BoolP("offline", "o", false, "Update bookmark without fetching data from internet")
|
||||
cmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt and update ALL bookmarks")
|
||||
cmd.Flags().Bool("dont-overwrite", false, "Don't overwrite existing metadata. Useful when only want to update bookmark's content")
|
||||
cmd.Flags().BoolP("no-archive", "a", false, "Update bookmark without creating offline archive")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -53,6 +54,7 @@ func updateHandler(cmd *cobra.Command, args []string) {
|
|||
tags, _ := cmd.Flags().GetStringSlice("tags")
|
||||
offline, _ := cmd.Flags().GetBool("offline")
|
||||
skipConfirm, _ := cmd.Flags().GetBool("yes")
|
||||
noArchival, _ := cmd.Flags().GetBool("no-archive")
|
||||
dontOverwrite := cmd.Flags().Changed("dont-overwrite")
|
||||
|
||||
// If no arguments (i.e all bookmarks going to be updated), confirm to user
|
||||
|
@ -74,6 +76,21 @@ func updateHandler(cmd *cobra.Command, args []string) {
|
|||
return
|
||||
}
|
||||
|
||||
// Check if user really want to batch update archive
|
||||
if len(ids) > 3 && !noArchival && !skipConfirm {
|
||||
fmt.Println("This update process will also generate the offline archive for the selected bookmarks.")
|
||||
fmt.Println("This might take a long time and a lot of your network bandwith.")
|
||||
|
||||
confirmUpdate := ""
|
||||
fmt.Printf("Continue update and archival process for %d bookmark(s)? (y/N): ", len(ids))
|
||||
fmt.Scanln(&confirmUpdate)
|
||||
|
||||
if confirmUpdate != "y" {
|
||||
fmt.Println("No bookmarks updated")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up new parameter from flags
|
||||
title = normalizeSpace(title)
|
||||
excerpt = normalizeSpace(excerpt)
|
||||
|
|
Loading…
Reference in a new issue