Skip to content
New issue

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

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

Already on GitHub? # to your account

Give CLI users the option to wrap or NOT wrap with directory #101

Merged
merged 1 commit into from
Nov 16, 2021
Merged
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
11 changes: 10 additions & 1 deletion src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface Flags {
list?: string,
listCids?: string
listRoots?: string
wrapWithDirectory?: boolean
}

const options = {
Expand Down Expand Up @@ -43,6 +44,11 @@ const options = {
},
listRoots: {
type: 'string'
},
wrapWithDirectory: {
type: 'boolean',
alias: 'w',
default: true
}
}
} as const;
Expand All @@ -63,6 +69,9 @@ const cli = meow(`
# specify the car file name.
$ ipfs-car --pack path/to/files --output path/to/write/a.car

# pack files without wrapping with top-level directory
$ ipfs-car --wrapWithDirectory false --pack path/to/files --output path/to/write/a.car

Unpacking files from a .car

# write 1 or more files to the current working dir.
Expand Down Expand Up @@ -96,7 +105,7 @@ const cli = meow(`

async function handleInput ({ flags }: { flags: Flags }) {
if (flags.pack) {
const { root, filename } = await packToFs({input: flags.pack, output: flags.output})
const { root, filename } = await packToFs({input: flags.pack, output: flags.output, wrapWithDirectory: flags.wrapWithDirectory})
// tslint:disable-next-line: no-console
console.log(`root CID: ${root.toString()}`)
// tslint:disable-next-line: no-console
Expand Down