mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 08:18:03 +08:00
files: make 'files ls' defaults to /
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
This commit is contained in:
parent
2600a0290a
commit
73e76dca56
@ -249,13 +249,21 @@ Examples:
|
||||
`,
|
||||
},
|
||||
Arguments: []cmds.Argument{
|
||||
cmds.StringArg("path", true, false, "Path to show listing for."),
|
||||
cmds.StringArg("path", false, false, "Path to show listing for. Defaults to '/'."),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption("l", "Use long listing format."),
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
path, err := checkPath(req.Arguments()[0])
|
||||
var arg string
|
||||
|
||||
if len(req.Arguments()) == 0 {
|
||||
arg = "/"
|
||||
} else {
|
||||
arg = req.Arguments()[0]
|
||||
}
|
||||
|
||||
path, err := checkPath(arg)
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
|
||||
@ -51,6 +51,12 @@ test_files_api() {
|
||||
ipfs files mkdir /cats
|
||||
'
|
||||
|
||||
test_expect_success "'files ls' lists root by default" '
|
||||
ipfs files ls >actual &&
|
||||
echo "cats" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "directory was created" '
|
||||
verify_path_exists /cats
|
||||
'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user