2023-02-04 21:21:27 +07:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2024-01-04 16:28:16 +07:00
|
|
|
* Copyright (c) 2022-2024, daeuniverse Organization <dae@v2raya.org>
|
2023-02-04 21:21:27 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
2023-04-23 12:27:29 +07:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2023-02-04 21:21:27 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
validateCmd = &cobra.Command{
|
|
|
|
Use: "validate",
|
2023-03-22 21:06:40 +07:00
|
|
|
Short: "To validate dae config.",
|
2023-02-04 21:21:27 +07:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
if cfgFile == "" {
|
2023-02-04 21:52:23 +07:00
|
|
|
fmt.Println("Argument \"--config\" or \"-c\" is required but not provided.")
|
|
|
|
os.Exit(1)
|
2023-02-04 21:21:27 +07:00
|
|
|
}
|
|
|
|
// Read config from --config cfgFile.
|
2023-02-09 22:17:49 +07:00
|
|
|
_, _, err := readConfig(cfgFile)
|
2023-02-04 21:21:27 +07:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2023-03-13 23:34:38 +07:00
|
|
|
rootCmd.AddCommand(validateCmd)
|
|
|
|
|
2023-02-04 21:21:27 +07:00
|
|
|
validateCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file")
|
|
|
|
}
|