This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Merged
files ls #1073
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f0c5aa0
feat: cli ls (#927)
rasmuserik b5b20fb
not using destructuring
rasmuserik 4d4be30
files ls
pgte 1d21f66
files.ls exposes a standard stream now
pgte f9ee120
added missing package
pgte 6ccac28
internal lsPull and options for js-ipfs-api compat
pgte 902449d
fixed test output
pgte e701492
chore: update deps
daviddias 1f3b1cd
ipfs.files.ls -> ipfs.ls + adapting core interface to HTTP API
pgte d72644e
chore: update deps
daviddias bf110e2
fix linting
daviddias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict' | ||
|
||
const utils = require('../utils') | ||
const Unixfs = require('ipfs-unixfs') | ||
const pull = require('pull-stream') | ||
|
||
module.exports = { | ||
command: 'ls <key>', | ||
|
||
describe: 'List files for the given directory', | ||
|
||
builder: { | ||
v: { | ||
alias: 'headers', | ||
desc: 'Print table headers (Hash, Size, Name).', | ||
type: 'boolean', | ||
default: false | ||
}, | ||
'resolve-type': { | ||
desc: 'Resolve linked objects to find out their types. (not implemented yet)', | ||
type: 'boolean', | ||
default: false // should be true when implemented | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
let path = argv.key | ||
if (path.startsWith('/ipfs/')) { | ||
path = path.replace('/ipfs/', '') | ||
} | ||
|
||
argv.ipfs.ls(path, (err, links) => { | ||
if (err) { | ||
throw err | ||
} | ||
|
||
if (argv.headers) { | ||
links = [{hash: 'Hash', size: 'Size', name: 'Name'}].concat(links) | ||
} | ||
|
||
links = links.filter((link) => link.path !== path) | ||
links.forEach((link) => { | ||
if (link.type === 'dir') { | ||
// directory: add trailing "/" | ||
link.name = (link.name || '') + '/' | ||
} | ||
}) | ||
const multihashWidth = Math.max.apply(null, links.map((file) => file.hash.length)) | ||
const sizeWidth = Math.max.apply(null, links.map((file) => String(file.size).length)) | ||
|
||
links.forEach((file) => { | ||
utils.print(utils.rightpad(file.hash, multihashWidth + 1) + | ||
utils.rightpad(file.size || '', sizeWidth + 1) + | ||
file.name) | ||
}) | ||
}) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
new CID(hash).toBaseEncodedString()
instead