修改两个文件,重新生成就可以了
- set GOOS=windows
- set GOARCH=amd64
- set CGO_ENABLED=0
- go build
复制代码
internal/pcscommand/tree.go
- import (
- "fmt"
- + "strconv"
- "github.com/qjfoidnh/BaiduPCS-Go/baidupcs"
- "strings"
- )
复制代码
- type (
- TreeOptions struct {
- Depth int
- + ShowSize bool
- ShowFsid bool
- }
- )
- +
- + func Format(n int64) string {
- + in := strconv.FormatInt(n, 10)
- + numOfDigits := len(in)
- + if n < 0 {
- + numOfDigits-- // First character is the - sign (not a digit)
- + }
- + numOfCommas := (numOfDigits - 1) / 3
- +
- + out := make([]byte, len(in)+numOfCommas)
- + if n < 0 {
- + in, out[0] = in[1:], '-'
- + }
- +
- + for i, j, k := len(in)-1, len(out)-1, 0; ; i, j = i-1, j-1 {
- + out[j] = in[i]
- + if i == 0 {
- + return string(out)
- + }
- + if k++; k == 3 {
- + j, k = j-1, 0
- + out[j] = ','
- + }
- + }
- + }
- func getTree(pcspath string, depth int, option *TreeOptions) {
复制代码
- if i+1 == fN {
- prefix = lastFilePrefix
- }
- + if option.ShowFsid && option.ShowSize {
- + fmt.Printf("%v%v %v: %v: %v\n", indentPrefixStr, prefix, file.Filename, Format(file.Size), file.FsID)
- + } else if option.ShowFsid {
- + fmt.Printf("%v%v %v: %v\n", indentPrefixStr, prefix, file.Filename, file.FsID)
- + } else if option.ShowSize {
- + fmt.Printf("%v%v %v: %v\n", indentPrefixStr, prefix, file.Filename, Format(file.Size))
- } else {
- fmt.Printf("%v%v %v\n", indentPrefixStr, prefix, file.Filename)
- }
复制代码
main.go
- Action: func(c *cli.Context) error {
- pcscommand.RunTree(c.Args().Get(0), 0, &pcscommand.TreeOptions{
- Depth: c.Int("depth"),
- + ShowSize: c.Bool("size"),
- ShowFsid: c.Bool("fsid"),
- })
- return nil
- },
- Flags: []cli.Flag{
- cli.IntFlag{
- Name: "depth",
- Usage: "显示深度",
- Value: -1,
- },
- + cli.BoolFlag{
- + Name: "size",
- + Usage: "带size显示",
- + },
- cli.BoolFlag{
- Name: "fsid",
- Usage: "带fsid显示",
- },
复制代码
|