Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

files: make 'files ls' defaults to / #2391

Merged
merged 1 commit into from
Feb 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions core/commands/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/sharness/t0250-files-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
Expand Down