Skip to content

Commit 774b4ae

Browse files
committed
rename cmdsutil to cmdkit (0.3.0) and publish 0.3.1
1 parent 541e33d commit 774b4ae

24 files changed

+193
-197
lines changed

.gx/lastpubver

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.0: QmZro8GXyJpJWtjrrSEr78dBdkZQ8ZnNjoCNB9FLEQWyRt
1+
0.3.1: QmeJXSetiGpUzubM2GQiWRQehrqKN4oAfNYoWxj8rH6xq3

chan.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"io"
77

8-
"gx/ipfs/QmWdiBLZ22juGtuNceNbvvHV11zKzCaoQFMP76x2w1XDFZ/go-ipfs-cmdkit"
8+
"gx/ipfs/QmeGapzEYCQkoEYN5x5MCPdj1zMGMHRjcPbA26sveo2XV4/go-ipfs-cmdkit"
99
)
1010

1111
func NewChanResponsePair(req Request) (ResponseEmitter, Response) {
@@ -33,7 +33,7 @@ func NewChanResponsePair(req Request) (ResponseEmitter, Response) {
3333
type chanResponse struct {
3434
req Request
3535

36-
err *cmdsutil.Error
36+
err *cmdkit.Error
3737
length uint64
3838

3939
// wait makes header requests block until the body is sent
@@ -50,7 +50,7 @@ func (r *chanResponse) Request() Request {
5050
return r.req
5151
}
5252

53-
func (r *chanResponse) Error() *cmdsutil.Error {
53+
func (r *chanResponse) Error() *cmdkit.Error {
5454
<-r.wait
5555

5656
if r == nil {
@@ -85,7 +85,7 @@ func (r *chanResponse) Next() (interface{}, error) {
8585
select {
8686
case v, ok := <-r.ch:
8787
if ok {
88-
if err, ok := v.(*cmdsutil.Error); ok {
88+
if err, ok := v.(*cmdkit.Error); ok {
8989
r.err = err
9090
return nil, ErrRcvdError
9191
}
@@ -107,13 +107,13 @@ type chanResponseEmitter struct {
107107
done <-chan struct{}
108108

109109
length *uint64
110-
err **cmdsutil.Error
110+
err **cmdkit.Error
111111

112112
emitted bool
113113
}
114114

115-
func (re *chanResponseEmitter) SetError(v interface{}, errType cmdsutil.ErrorType) {
116-
err := re.Emit(&cmdsutil.Error{Message: fmt.Sprint(v), Code: errType})
115+
func (re *chanResponseEmitter) SetError(v interface{}, errType cmdkit.ErrorType) {
116+
err := re.Emit(&cmdkit.Error{Message: fmt.Sprint(v), Code: errType})
117117
if err != nil {
118118
panic(err)
119119
}

cli/helptext.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"text/template"
99

1010
"github.com/ipfs/go-ipfs-cmds"
11-
"gx/ipfs/QmWdiBLZ22juGtuNceNbvvHV11zKzCaoQFMP76x2w1XDFZ/go-ipfs-cmdkit"
11+
"gx/ipfs/QmeGapzEYCQkoEYN5x5MCPdj1zMGMHRjcPbA26sveo2XV4/go-ipfs-cmdkit"
1212
)
1313

1414
const (
@@ -235,13 +235,13 @@ func generateSynopsis(cmd *cmds.Command, path string) string {
235235
if len(n) > 1 {
236236
pre = "--"
237237
}
238-
if opt.Type() == cmdsutil.Bool && opt.DefaultVal() == true {
238+
if opt.Type() == cmdkit.Bool && opt.DefaultVal() == true {
239239
pre = "--"
240240
sopt = fmt.Sprintf("%s%s=false", pre, n)
241241
break
242242
} else {
243243
if i == 0 {
244-
if opt.Type() == cmdsutil.Bool {
244+
if opt.Type() == cmdkit.Bool {
245245
sopt = fmt.Sprintf("%s%s", pre, n)
246246
} else {
247247
sopt = fmt.Sprintf("%s%s=<%s>", pre, n, valopt)
@@ -294,7 +294,7 @@ func optionFlag(flag string) string {
294294

295295
func optionText(cmd ...*cmds.Command) []string {
296296
// get a slice of the options we want to list out
297-
options := make([]cmdsutil.Option, 0)
297+
options := make([]cmdkit.Option, 0)
298298
for _, c := range cmd {
299299
for _, opt := range c.Options {
300300
options = append(options, opt)
@@ -393,7 +393,7 @@ func usageText(cmd *cmds.Command) string {
393393
return s
394394
}
395395

396-
func argUsageText(arg cmdsutil.Argument) string {
396+
func argUsageText(arg cmdkit.Argument) string {
397397
s := arg.Name
398398

399399
if arg.Required {

cli/helptext_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import (
55
"testing"
66

77
"github.com/ipfs/go-ipfs-cmds"
8-
"gx/ipfs/QmWdiBLZ22juGtuNceNbvvHV11zKzCaoQFMP76x2w1XDFZ/go-ipfs-cmdkit"
8+
"gx/ipfs/QmeGapzEYCQkoEYN5x5MCPdj1zMGMHRjcPbA26sveo2XV4/go-ipfs-cmdkit"
99
)
1010

1111
func TestSynopsisGenerator(t *testing.T) {
1212
command := &cmds.Command{
13-
Arguments: []cmdsutil.Argument{
14-
cmdsutil.StringArg("required", true, false, ""),
15-
cmdsutil.StringArg("variadic", false, true, ""),
13+
Arguments: []cmdkit.Argument{
14+
cmdkit.StringArg("required", true, false, ""),
15+
cmdkit.StringArg("variadic", false, true, ""),
1616
},
17-
Options: []cmdsutil.Option{
18-
cmdsutil.StringOption("opt", "o", "Option"),
17+
Options: []cmdkit.Option{
18+
cmdkit.StringOption("opt", "o", "Option"),
1919
},
20-
Helptext: cmdsutil.HelpText{
20+
Helptext: cmdkit.HelpText{
2121
SynopsisOptionsValues: map[string]string{
2222
"opt": "OPTION",
2323
},

cli/parse.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"strings"
1212

1313
"github.com/ipfs/go-ipfs-cmds"
14-
"gx/ipfs/QmWdiBLZ22juGtuNceNbvvHV11zKzCaoQFMP76x2w1XDFZ/go-ipfs-cmdkit"
15-
"gx/ipfs/QmWdiBLZ22juGtuNceNbvvHV11zKzCaoQFMP76x2w1XDFZ/go-ipfs-cmdkit/files"
14+
"gx/ipfs/QmeGapzEYCQkoEYN5x5MCPdj1zMGMHRjcPbA26sveo2XV4/go-ipfs-cmdkit"
15+
"gx/ipfs/QmeGapzEYCQkoEYN5x5MCPdj1zMGMHRjcPbA26sveo2XV4/go-ipfs-cmdkit/files"
1616

1717
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
1818
u "gx/ipfs/QmWbjfz3u6HkAdPh34dgPchGbQjob6LXLhAeCGii2TX69n/go-ipfs-util"
@@ -62,14 +62,14 @@ func Parse(input []string, stdin *os.File, root *cmds.Command) (cmds.Request, *c
6262
return req, cmd, path, cmd.CheckArguments(req)
6363
}
6464

65-
func ParseArgs(req cmds.Request, inputs []string, stdin *os.File, argDefs []cmdsutil.Argument, root *cmds.Command) ([]string, []files.File, error) {
65+
func ParseArgs(req cmds.Request, inputs []string, stdin *os.File, argDefs []cmdkit.Argument, root *cmds.Command) ([]string, []files.File, error) {
6666
var err error
6767

6868
// if -r is provided, and it is associated with the package builtin
6969
// recursive path option, allow recursive file paths
70-
recursiveOpt := req.Option(cmdsutil.RecShort)
70+
recursiveOpt := req.Option(cmdkit.RecShort)
7171
recursive := false
72-
if recursiveOpt != nil && recursiveOpt.Definition() == cmdsutil.OptionRecursivePath {
72+
if recursiveOpt != nil && recursiveOpt.Definition() == cmdkit.OptionRecursivePath {
7373
recursive, _, err = recursiveOpt.Bool()
7474
if err != nil {
7575
return nil, nil, u.ErrCast()
@@ -98,7 +98,7 @@ func parseOpts(args []string, root *cmds.Command) (
9898
) {
9999
path = make([]string, 0, len(args))
100100
stringVals = make([]string, 0, len(args))
101-
optDefs := map[string]cmdsutil.Option{}
101+
optDefs := map[string]cmdkit.Option{}
102102
opts = map[string]interface{}{}
103103
cmd = root
104104

@@ -120,7 +120,7 @@ func parseOpts(args []string, root *cmds.Command) (
120120
// eg. ipfs -r <file> means disregard <file> since there is no '='
121121
// mustUse == false in the above situation
122122
//arg == nil implies the flag was specified without an argument
123-
if optDef.Type() == cmdsutil.Bool {
123+
if optDef.Type() == cmdkit.Bool {
124124
if arg == nil || !mustUse {
125125
opts[name] = true
126126
return false, nil
@@ -255,7 +255,7 @@ func parseOpts(args []string, root *cmds.Command) (
255255

256256
const msgStdinInfo = "ipfs: Reading from %s; send Ctrl-d to stop."
257257

258-
func parseArgs(inputs []string, stdin *os.File, argDefs []cmdsutil.Argument, recursive, hidden bool, root *cmds.Command) ([]string, []files.File, error) {
258+
func parseArgs(inputs []string, stdin *os.File, argDefs []cmdkit.Argument, recursive, hidden bool, root *cmds.Command) ([]string, []files.File, error) {
259259
// ignore stdin on Windows
260260
if runtime.GOOS == "windows" {
261261
stdin = nil
@@ -304,7 +304,7 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmdsutil.Argument, rec
304304

305305
fillingVariadic := argDefIndex+1 > len(argDefs)
306306
switch argDef.Type {
307-
case cmdsutil.ArgString:
307+
case cmdkit.ArgString:
308308
if len(inputs) > 0 {
309309
stringArgs, inputs = append(stringArgs, inputs[0]), inputs[1:]
310310
} else if stdin != nil && argDef.SupportsStdin && !fillingVariadic {
@@ -313,7 +313,7 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmdsutil.Argument, rec
313313
stdin = nil
314314
}
315315
}
316-
case cmdsutil.ArgFile:
316+
case cmdkit.ArgFile:
317317
if len(inputs) > 0 {
318318
// treat stringArg values as file paths
319319
fpath := inputs[0]
@@ -380,7 +380,7 @@ func filesMapToSortedArr(fs map[string]files.File) []files.File {
380380
return out
381381
}
382382

383-
func getArgDef(i int, argDefs []cmdsutil.Argument) *cmdsutil.Argument {
383+
func getArgDef(i int, argDefs []cmdkit.Argument) *cmdkit.Argument {
384384
if i < len(argDefs) {
385385
// get the argument definition (usually just argDefs[i])
386386
return &argDefs[i]
@@ -397,7 +397,7 @@ func getArgDef(i int, argDefs []cmdsutil.Argument) *cmdsutil.Argument {
397397
const notRecursiveFmtStr = "'%s' is a directory, use the '-%s' flag to specify directories"
398398
const dirNotSupportedFmtStr = "Invalid path '%s', argument '%s' does not support directories"
399399

400-
func appendFile(fpath string, argDef *cmdsutil.Argument, recursive, hidden bool) (files.File, error) {
400+
func appendFile(fpath string, argDef *cmdkit.Argument, recursive, hidden bool) (files.File, error) {
401401
if fpath == "." {
402402
cwd, err := os.Getwd()
403403
if err != nil {
@@ -422,7 +422,7 @@ func appendFile(fpath string, argDef *cmdsutil.Argument, recursive, hidden bool)
422422
return nil, fmt.Errorf(dirNotSupportedFmtStr, fpath, argDef.Name)
423423
}
424424
if !recursive {
425-
return nil, fmt.Errorf(notRecursiveFmtStr, fpath, cmdsutil.RecShort)
425+
return nil, fmt.Errorf(notRecursiveFmtStr, fpath, cmdkit.RecShort)
426426
}
427427
}
428428

cli/parse_test.go

+29-29
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/ipfs/go-ipfs-cmds"
12-
"gx/ipfs/QmWdiBLZ22juGtuNceNbvvHV11zKzCaoQFMP76x2w1XDFZ/go-ipfs-cmdkit"
12+
"gx/ipfs/QmeGapzEYCQkoEYN5x5MCPdj1zMGMHRjcPbA26sveo2XV4/go-ipfs-cmdkit"
1313
)
1414

1515
type kvs map[string]interface{}
@@ -69,9 +69,9 @@ func TestSameWords(t *testing.T) {
6969
func TestOptionParsing(t *testing.T) {
7070
subCmd := &cmds.Command{}
7171
cmd := &cmds.Command{
72-
Options: []cmdsutil.Option{
73-
cmdsutil.StringOption("string", "s", "a string"),
74-
cmdsutil.BoolOption("bool", "b", "a bool"),
72+
Options: []cmdkit.Option{
73+
cmdkit.StringOption("string", "s", "a string"),
74+
cmdkit.BoolOption("bool", "b", "a bool"),
7575
},
7676
Subcommands: map[string]*cmds.Command{
7777
"test": subCmd,
@@ -146,58 +146,58 @@ func TestArgumentParsing(t *testing.T) {
146146
Subcommands: map[string]*cmds.Command{
147147
"noarg": {},
148148
"onearg": {
149-
Arguments: []cmdsutil.Argument{
150-
cmdsutil.StringArg("a", true, false, "some arg"),
149+
Arguments: []cmdkit.Argument{
150+
cmdkit.StringArg("a", true, false, "some arg"),
151151
},
152152
},
153153
"twoargs": {
154-
Arguments: []cmdsutil.Argument{
155-
cmdsutil.StringArg("a", true, false, "some arg"),
156-
cmdsutil.StringArg("b", true, false, "another arg"),
154+
Arguments: []cmdkit.Argument{
155+
cmdkit.StringArg("a", true, false, "some arg"),
156+
cmdkit.StringArg("b", true, false, "another arg"),
157157
},
158158
},
159159
"variadic": {
160-
Arguments: []cmdsutil.Argument{
161-
cmdsutil.StringArg("a", true, true, "some arg"),
160+
Arguments: []cmdkit.Argument{
161+
cmdkit.StringArg("a", true, true, "some arg"),
162162
},
163163
},
164164
"optional": {
165-
Arguments: []cmdsutil.Argument{
166-
cmdsutil.StringArg("b", false, true, "another arg"),
165+
Arguments: []cmdkit.Argument{
166+
cmdkit.StringArg("b", false, true, "another arg"),
167167
},
168168
},
169169
"optionalsecond": {
170-
Arguments: []cmdsutil.Argument{
171-
cmdsutil.StringArg("a", true, false, "some arg"),
172-
cmdsutil.StringArg("b", false, false, "another arg"),
170+
Arguments: []cmdkit.Argument{
171+
cmdkit.StringArg("a", true, false, "some arg"),
172+
cmdkit.StringArg("b", false, false, "another arg"),
173173
},
174174
},
175175
"reversedoptional": {
176-
Arguments: []cmdsutil.Argument{
177-
cmdsutil.StringArg("a", false, false, "some arg"),
178-
cmdsutil.StringArg("b", true, false, "another arg"),
176+
Arguments: []cmdkit.Argument{
177+
cmdkit.StringArg("a", false, false, "some arg"),
178+
cmdkit.StringArg("b", true, false, "another arg"),
179179
},
180180
},
181181
"stdinenabled": {
182-
Arguments: []cmdsutil.Argument{
183-
cmdsutil.StringArg("a", true, true, "some arg").EnableStdin(),
182+
Arguments: []cmdkit.Argument{
183+
cmdkit.StringArg("a", true, true, "some arg").EnableStdin(),
184184
},
185185
},
186186
"stdinenabled2args": &cmds.Command{
187-
Arguments: []cmdsutil.Argument{
188-
cmdsutil.StringArg("a", true, false, "some arg"),
189-
cmdsutil.StringArg("b", true, true, "another arg").EnableStdin(),
187+
Arguments: []cmdkit.Argument{
188+
cmdkit.StringArg("a", true, false, "some arg"),
189+
cmdkit.StringArg("b", true, true, "another arg").EnableStdin(),
190190
},
191191
},
192192
"stdinenablednotvariadic": &cmds.Command{
193-
Arguments: []cmdsutil.Argument{
194-
cmdsutil.StringArg("a", true, false, "some arg").EnableStdin(),
193+
Arguments: []cmdkit.Argument{
194+
cmdkit.StringArg("a", true, false, "some arg").EnableStdin(),
195195
},
196196
},
197197
"stdinenablednotvariadic2args": &cmds.Command{
198-
Arguments: []cmdsutil.Argument{
199-
cmdsutil.StringArg("a", true, false, "some arg"),
200-
cmdsutil.StringArg("b", true, false, "another arg").EnableStdin(),
198+
Arguments: []cmdkit.Argument{
199+
cmdkit.StringArg("a", true, false, "some arg"),
200+
cmdkit.StringArg("b", true, false, "another arg").EnableStdin(),
201201
},
202202
},
203203
},

0 commit comments

Comments
 (0)