You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1023 B
Go
47 lines
1023 B
Go
2 years ago
|
package detach
|
||
|
|
||
|
import (
|
||
|
"b612.me/starcrypto"
|
||
|
"fmt"
|
||
|
|
||
|
"b612.me/starlog"
|
||
|
"github.com/spf13/cobra"
|
||
|
)
|
||
|
|
||
|
var Cmd = &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.Criticalln("ERROR PATH")
|
||
|
this.Help()
|
||
|
return
|
||
|
}
|
||
|
err := starcrypto.Detach(src, num, dst, out)
|
||
|
if err != nil {
|
||
|
starlog.Criticalln(err.Error)
|
||
|
} else {
|
||
|
fmt.Println("完成")
|
||
|
}
|
||
|
},
|
||
|
}
|
||
|
|
||
|
func init() {
|
||
|
Cmd.Flags().StringP("src", "s", "", "源文件路径")
|
||
|
Cmd.Flags().StringP("dst", "d", "", "目标文件路径1")
|
||
|
Cmd.Flags().StringP("out", "o", "", "目标文件路径2")
|
||
|
Cmd.Flags().IntP("num", "n", 0, "分割开始字节")
|
||
|
}
|