Skip to content

Commit

Permalink
cobra usage
Browse files Browse the repository at this point in the history
  • Loading branch information
visill committed Aug 4, 2024
1 parent fc134ce commit 2dfb086
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
22 changes: 11 additions & 11 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"

"github.com/yezzey-gp/yproxy/pkg/storage"
"github.com/yezzey-gp/yproxy/pkg/utils"

"github.com/spf13/cobra"
"github.com/yezzey-gp/yproxy/config"
Expand All @@ -25,14 +24,11 @@ var encrypt bool
var offset uint64

// TODOV
func Runner(f func(net.Conn, *config.Instance, []string) error, argChecker func([]string) error) func(*cobra.Command, []string) error {
func Runner(f func(net.Conn, *config.Instance, []string) error) func(*cobra.Command, []string) error {

return func(cmd *cobra.Command, args []string) error {
err := argChecker(args)
if err != nil {
return err
}
err = config.LoadInstanceConfig(cfgPath)

err := config.LoadInstanceConfig(cfgPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -206,25 +202,29 @@ var rootCmd = &cobra.Command{
var catCmd = &cobra.Command{
Use: "cat",
Short: "cat",
RunE: Runner(catFunc, utils.OneArg),
Args: cobra.ExactArgs(1),
RunE: Runner(catFunc),
}

var copyCmd = &cobra.Command{
Use: "copy",
Short: "copy",
RunE: Runner(copyFunc, utils.OneArg),
Args: cobra.ExactArgs(1),
RunE: Runner(copyFunc),
}

var putCmd = &cobra.Command{
Use: "put",
Short: "put",
RunE: Runner(putFunc, utils.OneArg),
Args: cobra.ExactArgs(1),
RunE: Runner(putFunc),
}

var listCmd = &cobra.Command{
Use: "list",
Short: "list",
RunE: Runner(listFunc, utils.OneArg),
Args: cobra.ExactArgs(1),
RunE: Runner(listFunc),
}

func init() {
Expand Down
26 changes: 0 additions & 26 deletions pkg/utils/argcheckers.go

This file was deleted.

0 comments on commit 2dfb086

Please sign in to comment.