SHARE
TWEET

Untitled

klim0v Feb 14th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package cmd
  2.  
  3. import (
  4.     "github.com/MinterTeam/minter-go-node/cli/service"
  5.     "github.com/MinterTeam/minter-go-node/cmd/utils"
  6.     "github.com/spf13/cobra"
  7.     "strings"
  8. )
  9.  
  10. var ManagerCommand = &cobra.Command{
  11.     Use:                "manager",
  12.     Short:              "Minter manager execute command",
  13.     DisableFlagParsing: true,
  14.     RunE: func(cmd *cobra.Command, args []string) error {
  15.         newArgs := setParentFlags(cmd,args)
  16.         console, err := service.ConfigureManagerConsole(utils.GetMinterHome() + "/manager.sock")
  17.         if err != nil {
  18.             return nil
  19.         }
  20.         return console.Execute(newArgs)
  21.     },
  22. }
  23.  
  24. var ManagerConsole = &cobra.Command{
  25.     Use:                "console",
  26.     Short:              "Minter CLI manager",
  27.     DisableFlagParsing: true,
  28.     RunE: func(cmd *cobra.Command, args []string) error {
  29.         _ = setParentFlags(cmd,args)
  30.         console, err := service.ConfigureManagerConsole(utils.GetMinterHome() + "/manager.sock")
  31.         if err != nil {
  32.             return nil
  33.         }
  34.         console.Cli()
  35.         return nil
  36.     },
  37. }
  38.  
  39. func setParentFlags(cmd *cobra.Command, args []string) (newArgs []string){
  40.     for _, arg := range args {
  41.         split := strings.Split(arg, "=")
  42.         if len(split) == 2 {
  43.             err := cmd.Parent().PersistentFlags().Set(strings.TrimLeft(split[0], "-"), split[1])
  44.             if err == nil {
  45.                 continue
  46.             }
  47.         }
  48.         newArgs = append(newArgs, arg)
  49.     }
  50.     return newArgs
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top