mirror of
https://github.com/go-shiori/shiori.git
synced 2025-02-23 07:26:01 +08:00
Update commands and its description
This commit is contained in:
parent
ed95ef98ad
commit
1fe1b22821
2 changed files with 15 additions and 7 deletions
|
@ -10,7 +10,7 @@ import (
|
||||||
var (
|
var (
|
||||||
addCmd = &cobra.Command{
|
addCmd = &cobra.Command{
|
||||||
Use: "add url",
|
Use: "add url",
|
||||||
Short: "Bookmark URL with comma-separated tags.",
|
Short: "Bookmark the specified URL.",
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
// Read flag and arguments
|
// Read flag and arguments
|
||||||
|
|
|
@ -11,11 +11,15 @@ var (
|
||||||
Use: "delete [indices]",
|
Use: "delete [indices]",
|
||||||
Short: "Delete the saved bookmarks.",
|
Short: "Delete the saved bookmarks.",
|
||||||
Long: "Delete bookmarks. " +
|
Long: "Delete bookmarks. " +
|
||||||
|
"When a record is deleted, the last record is moved to the removed index. " +
|
||||||
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45) and hyphenated range (e.g. 100-200). " +
|
"Accepts space-separated list of indices (e.g. 5 6 23 4 110 45) and hyphenated range (e.g. 100-200). " +
|
||||||
"If no arguments, all records will be deleted",
|
"If no arguments, all records will be deleted",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
// Read flags
|
||||||
|
skipConfirmation, _ := cmd.Flags().GetBool("yes")
|
||||||
|
|
||||||
// If no arguments, confirm to user
|
// If no arguments, confirm to user
|
||||||
if len(args) == 0 {
|
if len(args) == 0 && !skipConfirmation {
|
||||||
confirmDelete := ""
|
confirmDelete := ""
|
||||||
fmt.Print("Remove ALL bookmarks? (y/n): ")
|
fmt.Print("Remove ALL bookmarks? (y/n): ")
|
||||||
fmt.Scanln(&confirmDelete)
|
fmt.Scanln(&confirmDelete)
|
||||||
|
@ -33,17 +37,21 @@ var (
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(oldIndices) == 0 {
|
||||||
|
fmt.Println("No bookmarks deleted")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("Bookmarks has been deleted")
|
fmt.Println("Bookmarks has been deleted")
|
||||||
if len(oldIndices) > 0 {
|
for i, oldIndex := range oldIndices {
|
||||||
for i, oldIndex := range oldIndices {
|
newIndex := newIndices[i]
|
||||||
newIndex := newIndices[i]
|
fmt.Printf("Index %d moved to %d\n", oldIndex, newIndex)
|
||||||
fmt.Printf("Index %d moved to %d\n", oldIndex, newIndex)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
deleteCmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt and delete ALL bookmarks")
|
||||||
rootCmd.AddCommand(deleteCmd)
|
rootCmd.AddCommand(deleteCmd)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue