41 lines
855 B
Go
41 lines
855 B
Go
package importer
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func setupCommands(i *Importer) *cobra.Command {
|
|
rootCmd := &cobra.Command{
|
|
Use: "importer",
|
|
Short: "Importer is a CLI for importing data into the directory",
|
|
}
|
|
|
|
importCmd := &cobra.Command{
|
|
Use: "import",
|
|
Short: "Import data into the directory",
|
|
}
|
|
|
|
importJSONCmd := &cobra.Command{
|
|
Use: "json [file]",
|
|
Short: "Import data from a JSON file",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
i.importFromJSON(args[0])
|
|
},
|
|
}
|
|
|
|
importOPMLCmd := &cobra.Command{
|
|
Use: "opml [file]",
|
|
Short: "Import data from an OPML file",
|
|
Args: cobra.ExactArgs(1),
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
i.importFromOPML(args[0])
|
|
},
|
|
}
|
|
|
|
importCmd.AddCommand(importJSONCmd, importOPMLCmd)
|
|
rootCmd.AddCommand(importCmd)
|
|
|
|
return rootCmd
|
|
}
|