generated from alecodes/base-template
feat: add basic command structure
This commit is contained in:
parent
c8a37ed85c
commit
1459abdd84
8 changed files with 78 additions and 3 deletions
46
cmd/archive.go
Normal file
46
cmd/archive.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var Services = []string{
|
||||
"linkding",
|
||||
}
|
||||
|
||||
var (
|
||||
service_host string
|
||||
service_user string
|
||||
service_token string
|
||||
)
|
||||
|
||||
// archiveCmd represents the archive command
|
||||
var archiveCmd = &cobra.Command{
|
||||
Use: "archive",
|
||||
Short: "Archive the rss entries to an external service.",
|
||||
Aliases: []string{"run"},
|
||||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
|
||||
ValidArgs: Services,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// service := args[0]
|
||||
fmt.Printf("%v", viper.AllSettings())
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(archiveCmd)
|
||||
|
||||
archiveCmd.Flags().StringVar(&service_host, "service-host", "", "127.0.0.1")
|
||||
archiveCmd.Flags().StringVar(&service_user, "service-user", "", "john.doe@mail.cl")
|
||||
archiveCmd.Flags().StringVar(&service_token, "service-token", "", "XXX-XXX-XXX")
|
||||
|
||||
viper.BindPFlag("service_host", archiveCmd.Flags().Lookup("service-host"))
|
||||
viper.BindPFlag("service_host", archiveCmd.Flags().Lookup("service-host"))
|
||||
viper.BindPFlag("service_token", archiveCmd.Flags().Lookup("service-token"))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue