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.
star/merge/merge.go

47 lines
920 B
Go

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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