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.
|
|
|
|
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", "", "目标文件地址")
|
|
|
|
|
}
|