dae/cmd/validate.go

39 lines
735 B
Go
Raw Permalink Normal View History

2023-02-04 21:21:27 +07:00
/*
* SPDX-License-Identifier: AGPL-3.0-only
* Copyright (c) 2022-2024, daeuniverse Organization <dae@v2raya.org>
2023-02-04 21:21:27 +07:00
*/
package cmd
import (
"fmt"
"os"
"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")
}