Add option to only add unique cards
This commit is contained in:
parent
a7606055c9
commit
39b13c0763
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
addCmd.Flags().Int64VarP(&count, "count", "c", 1, "Amount of cards to add")
|
addCmd.Flags().Int64VarP(&count, "count", "c", 1, "Amount of cards to add")
|
||||||
|
addCmd.Flags().BoolVarP(&unique, "unique", "u", false, "Only add card if not existent yet")
|
||||||
rootCmd.AddCommand(addCmd)
|
rootCmd.AddCommand(addCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,6 +40,12 @@ var addCmd = &cobra.Command{
|
|||||||
|
|
||||||
// If duplicate key, increase count of card
|
// If duplicate key, increase count of card
|
||||||
if mongo.IsDuplicateKeyError(err) {
|
if mongo.IsDuplicateKeyError(err) {
|
||||||
|
|
||||||
|
if unique {
|
||||||
|
LogMessage(fmt.Sprintf("Not adding \"%s\" to Collection because it already exists.", c.Name), "red")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
modify_count_of_card(coll, c, count)
|
modify_count_of_card(coll, c, count)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ var limit float64
|
|||||||
var name string
|
var name string
|
||||||
var since string
|
var since string
|
||||||
var rarity, set, sort string
|
var rarity, set, sort string
|
||||||
|
var unique bool
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Version: Version,
|
Version: Version,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user