This repository has been archived by the owner on Dec 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
79 lines (71 loc) · 1.92 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import car from './commands/car/index.js'
import delegations from './commands/delegations/index.js'
import id from './commands/id.js'
import info from './commands/info.js'
// import insights from './commands/insights.js'
import open from './commands/open.js'
import register from './commands/register.js'
import settings from './commands/settings/index.js'
import store from './commands/store/index.js'
import upload from './commands/upload.js'
import uploadCars from './commands/uploadCars.js'
import uploads from './commands/uploads/index.js'
import list from './commands/uploads/list.js'
import whoami from './commands/whoami.js'
import printQuickstart from './quickstart.js'
import _yargs from 'yargs'
import { hideBin } from 'yargs/helpers'
/**
* @param {string[]} args
*/
export const main = async (args = hideBin(process.argv)) => {
const yargs = _yargs(args)
const argv = await yargs
.scriptName('w3up')
// .usage('Usage:\n $0 <cmd> [options]')
.option('p', {
alias: 'profile',
type: 'string',
describe: 'Select profile configuration identifier.',
default: 'main'
})
.group('profile', 'Global:')
.command({
command: '*',
handler () {
printQuickstart()
yargs.showHelp()
}
})
.command({
command: 'completion',
handler () {
yargs.showCompletionScript()
}
})
// registration
.command(id)
.command(register)
.command(whoami)
// uploads
.command(list)
.command(upload)
.command(uploadCars)
// utils
.command(open)
// subcommands
.command(settings)
.command(store)
.command(uploads)
.command(delegations)
.command(car)
.command(info)
.help()
// .showHelpOnFail(true)
.demandCommand(1, '')
.recommendCommands()
.strict()
.wrap(yargs.terminalWidth())
.epilog('Docs:\n https://github.com/web3-storage/w3up-cli').argv
return argv
}