Add json export
This commit is contained in:
parent
07e9a962d2
commit
4cb840558f
@ -1,6 +1,7 @@
|
|||||||
package serra
|
package serra
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -8,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
exportCmd.Flags().StringVarP(&set, "set", "e", "", "Filter by set code (usg/mmq/vow)")
|
exportCmd.Flags().StringVarP(&set, "set", "e", "", "Filter by set code (usg/mmq/vow)")
|
||||||
exportCmd.Flags().StringVarP(&format, "format", "f", "tcgpowertools", "Choose format to export (tcgpowertools)")
|
exportCmd.Flags().StringVarP(&format, "format", "f", "tcgpowertools", "Choose format to export (tcgpowertools/json)")
|
||||||
rootCmd.AddCommand(exportCmd)
|
rootCmd.AddCommand(exportCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,6 +26,8 @@ var exportCmd = &cobra.Command{
|
|||||||
switch format {
|
switch format {
|
||||||
case "tcgpowertools":
|
case "tcgpowertools":
|
||||||
exportTCGPowertools(cardList)
|
exportTCGPowertools(cardList)
|
||||||
|
case "json":
|
||||||
|
exportJson(cardList)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -41,3 +44,8 @@ func exportTCGPowertools(cards []Card) {
|
|||||||
fmt.Printf("%.0f,%d,%s,%s,EX,German,false,false,,,%.2f,\n", card.CardmarketID, card.SerraCount, card.Name, card.SetName, card.getValue(false))
|
fmt.Printf("%.0f,%d,%s,%s,EX,German,false,false,,,%.2f,\n", card.CardmarketID, card.SerraCount, card.Name, card.SetName, card.getValue(false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exportJson(cards []Card) {
|
||||||
|
ehj, _ := json.MarshalIndent(cards, "", " ")
|
||||||
|
fmt.Println(string(ehj))
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user