Codevault initial commit
This commit is contained in:
31
cmd/config_example.go
Normal file
31
cmd/config_example.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user