Skip to content

Commit c747239

Browse files
[DO NOT MERGE] Create dir patch (#152)
* add message on success * lint fix * spacing fix * fix(gosdk): upgraded gosdk with 5a2ddeaba15293d970fa8eb8a8f721d1da6a2cb2 * fix(gosdk): upgraded gosdk with ccd335913d4cc0b0dc31a27cb2e0eb35ef614eaf * fix(gomod): upgraded gosdk and removed homedir * fix(gomod): upgraded gosdk with 3db80b0bbdbcce6ef619c17eabaa47db26004341 * point to gosdk branch with errorGroups * point to errorHandling gosdk branch * fix(gomod): upgraded gosdk with fb3f710e452b3bae9763cff8d7a613d6e29f9a04 * fix(gomod): upgraded gosdk with 1e37d2ba4e8aa5dd2f2913c3b3350e9179444c32 Co-authored-by: Lz <imlangzi@qq.com>
1 parent 5ef3c03 commit c747239

File tree

4 files changed

+67
-22
lines changed

4 files changed

+67
-22
lines changed

cmd/upload.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"context"
5+
"fmt"
56
"log"
67
"os"
78
"path/filepath"
@@ -37,23 +38,23 @@ var createDirCmd = &cobra.Command{
3738
allocationID := cmd.Flag("allocation").Value.String()
3839
allocationObj, err := sdk.GetAllocation(allocationID)
3940
if err != nil {
40-
PrintError("Error fetching the allocation.", err)
41+
PrintError("Error fetching the allocation", err)
4142
os.Exit(1)
4243
}
4344
dirname := cmd.Flag("dirname").Value.String()
4445

4546
if err != nil {
46-
PrintError("CreateDir failed.", err)
47+
PrintError("CreateDir failed: ", err)
4748
os.Exit(1)
4849
}
4950
err = allocationObj.CreateDir(dirname)
5051

5152
if err != nil {
52-
PrintError("CreateDir failed.", err)
53+
PrintError("CreateDir failed: ", err)
5354
os.Exit(1)
5455
}
5556

56-
return
57+
fmt.Println(dirname + " directory created")
5758
},
5859
}
5960

@@ -64,17 +65,17 @@ var uploadCmd = &cobra.Command{
6465
Long: `upload file to blobbers`,
6566
Args: cobra.MinimumNArgs(0),
6667
Run: func(cmd *cobra.Command, args []string) {
67-
fflags := cmd.Flags() // fflags is a *flag.FlagSet
68-
if fflags.Changed("allocation") == false { // check if the flag "path" is set
68+
fflags := cmd.Flags() // fflags is a *flag.FlagSet
69+
if !fflags.Changed("allocation") { // check if the flag "path" is set
6970
PrintError("Error: allocation flag is missing") // If not, we'll let the user know
7071
os.Exit(1) // and return
7172
}
72-
if fflags.Changed("remotepath") == false {
73+
if !fflags.Changed("remotepath") {
7374
PrintError("Error: remotepath flag is missing")
7475
os.Exit(1)
7576
}
7677

77-
if fflags.Changed("localpath") == false {
78+
if !fflags.Changed("localpath") {
7879
PrintError("Error: localpath flag is missing")
7980
os.Exit(1)
8081
}
@@ -141,8 +142,6 @@ var uploadCmd = &cobra.Command{
141142
commitMetaTxn(remotepath, "Upload", "", "", allocationObj, nil, statusBar)
142143
statusBar.wg.Wait()
143144
}
144-
145-
return
146145
},
147146
}
148147

go.mod

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ go 1.13
44

55
require (
66
github.com/0chain/errors v1.0.3
7-
github.com/0chain/gosdk v1.4.1-0.20211230150557-0a53b79512fa
8-
github.com/mitchellh/go-homedir v1.1.0
7+
github.com/0chain/gosdk v1.4.1-0.20220105140556-1e37d2ba4e8a
98
github.com/olekukonko/tablewriter v0.0.5
109
github.com/spf13/cobra v1.1.1
1110
github.com/spf13/pflag v1.0.5
1211
gopkg.in/cheggaaa/pb.v1 v1.0.28
1312
)
1413

1514
// temporary, for development
16-
// replace github.com/0chain/gosdk => ../gosdk
15+
//replace github.com/0chain/gosdk => ../gosdk

0 commit comments

Comments
 (0)