-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
executable file
·42 lines (38 loc) · 803 Bytes
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
import meow from 'meow'
import { ipfsGet } from './index.js'
const options = {
importMeta: import.meta,
flags: {
gateway: {
type: 'string',
alias: 'g',
default: 'https://ipfs.io'
},
output: {
type: 'string',
alias: 'o'
},
quiet: {
type: 'boolean',
alias: 'q'
}
}
}
const cli = meow(`
Usage
$ ipfs-get <cid> [--gateway https://ipfs.io] [--output <path>]
Example
$ ipfs-get bafkreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy --output guardian.jpg
Options
--gateway <URL> the ipfs gateway to fetch the cid from as a CAR
--output <path> where to write the output to
--quiet say nothing
`, options)
if (!cli.input[0]) {
cli.showHelp()
}
ipfsGet({
ipfsPath: cli.input[0],
...cli.flags
})