star/merge/merge.go
2023-04-04 14:11:09 +08:00

47 lines
920 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package merge
import (
"b612.me/starcrypto"
"fmt"
"b612.me/starlog"
"github.com/spf13/cobra"
)
var Cmd = &cobra.Command{
Use: "merge",
Short: "合并文件",
Long: "按路径自动合并分割的文件",
Run: func(this *cobra.Command, args []string) {
var src, dst string
if len(args) == 2 {
src = args[0]
dst = args[1]
} else {
src, _ = this.Flags().GetString("src")
dst, _ = this.Flags().GetString("dst")
}
if src == "" || dst == "" {
this.Help()
return
}
err := starcrypto.MergeFile(src, dst, func(pect float64) {
if pect == 100 {
fmt.Println("文件已处理100.000000%")
} else {
fmt.Printf("文件已处理:%f%%\r", pect)
}
})
if err != nil {
starlog.Errorln(err.Error)
}
},
}
func init() {
Cmd.Flags().StringP("src", "s", "", "源文件地址,用*替换文件数字")
Cmd.Flags().StringP("dst", "d", "", "目标文件地址")
}