dae/cmd/validate.go
czybjtu e71c272693
style: format golang import package code style (#58)
Co-authored-by: Kevin Yu <yqlbu@Bu.edu>
2023-04-23 13:27:29 +08:00

39 lines
735 B
Go

/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (c) 2022-2023, daeuniverse Organization <dae@v2raya.org>
*/
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var (
validateCmd = &cobra.Command{
Use: "validate",
Short: "To validate dae config.",
Run: func(cmd *cobra.Command, args []string) {
if cfgFile == "" {
fmt.Println("Argument \"--config\" or \"-c\" is required but not provided.")
os.Exit(1)
}
// Read config from --config cfgFile.
_, _, err := readConfig(cfgFile)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
},
}
)
func init() {
rootCmd.AddCommand(validateCmd)
validateCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file")
}