dae/cmd/validate.go
2024-01-04 17:28:16 +08:00

39 lines
735 B
Go

/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (c) 2022-2024, 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")
}