package tools import ( "fmt" "b612.me/starainrt" "b612.me/starlog" "github.com/spf13/cobra" ) var detachcmd = &cobra.Command{ Use: "detach", Short: "分离两个文件", Long: "分离两个文件", Run: func(this *cobra.Command, args []string) { var src, dst, out string if len(args) == 3 { src = args[0] dst = args[1] out = args[2] } else { src, _ = this.Flags().GetString("src") dst, _ = this.Flags().GetString("dst") out, _ = this.Flags().GetString("out") } num, _ := this.Flags().GetInt("num") if src == "" || dst == "" { starlog.Println("ERROR PATH", "red", "b") this.Help() return } cryp := new(starainrt.StarCrypto) err := cryp.Detach(src, num, dst, out) if err != nil { starlog.Println(err.Error, "red", "b") } else { fmt.Println("完成") } }, } func init() { detachcmd.Flags().StringP("src", "s", "", "源文件路径") detachcmd.Flags().StringP("dst", "d", "", "目标文件路径1") detachcmd.Flags().StringP("out", "o", "", "目标文件路径2") detachcmd.Flags().IntP("num", "n", 0, "分割开始字节") Maincmd.AddCommand(detachcmd) }