Skip to content

Commit

Permalink
feat(command): merge file ls and ls
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
  • Loading branch information
overbool committed Sep 21, 2018
1 parent 987fef1 commit 17a3f9a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
type LsLink struct {
Name, Hash string
Size uint64
Type unixfspb.Data_DataType
Type string
}

type LsObject struct {
Expand All @@ -48,6 +48,15 @@ the following format:
<link base58 hash> <link size in bytes> <link name>
The JSON output contains type information.
The path can be a prefixless ref; in this case, we assume it to be an
/ipfs ref and not /ipns.
Example:
> ipfs file ls QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ
cat.jpg
> ipfs file ls /ipfs/QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ
cat.jpg
`,
},

Expand Down Expand Up @@ -162,7 +171,7 @@ The JSON output contains type information.
Name: link.Name,
Hash: link.Cid.String(),
Size: link.Size,
Type: t,
Type: t.String(),
}
}
}
Expand Down Expand Up @@ -193,7 +202,7 @@ The JSON output contains type information.
fmt.Fprintln(w, "Hash\tSize\tName")
}
for _, link := range object.Links {
if link.Type == unixfspb.Data_Directory {
if link.Type == unixfspb.Data_Directory.String() {
link.Name += "/"
}
fmt.Fprintf(w, "%s\t%v\t%s\n", link.Hash, link.Size, link.Name)
Expand Down

0 comments on commit 17a3f9a

Please # to comment.