32 lines
675 B
Go
32 lines
675 B
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/kanootoko/codevault/internal/runcmd"
|
|
)
|
|
|
|
var configExampleCmd = &cobra.Command{
|
|
Use: "config-example <config-path>",
|
|
Short: "Get server config example",
|
|
Long: `Generate and save to file a sample config for further manual editing.`,
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
configPath := args[0]
|
|
|
|
err := runcmd.ConfigExample(configPath)
|
|
if err != nil && !errors.Is(err, context.Canceled) {
|
|
return fmt.Errorf("error on saving example config: %w", err)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(configExampleCmd)
|
|
}
|