MCPcopy Create free account
hub / github.com/Easy-Editor/EasyEditor / cli

Function cli

packages/easypack/src/cli/index.ts:49–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49export async function cli(): Promise<void> {
50 const argv = mri<CliArgs>(process.argv.slice(2), {
51 alias: {
52 h: 'help',
53 v: 'version',
54 c: 'config',
55 p: 'preset',
56 },
57 boolean: ['help', 'version'],
58 string: ['config', 'preset'],
59 })
60
61 // 显示版本
62 if (argv.version) {
63 console.log(VERSION)
64 return
65 }
66
67 // 显示帮助或无命令时
68 if (argv.help || argv._.length === 0) {
69 console.log(helpMessage)
70 return
71 }
72
73 const command = argv._[0]
74
75 try {
76 switch (command) {
77 case 'build':
78 await buildCommand(argv)
79 break
80 case 'dev':
81 await devCommand(argv)
82 break
83 case 'init':
84 await initCommand(argv)
85 break
86 default:
87 console.log(pc.red(`Unknown command: ${command}`))
88 console.log(helpMessage)
89 process.exit(1)
90 }
91 } catch (error) {
92 console.error(pc.red('Error:'), error instanceof Error ? error.message : error)
93 process.exit(1)
94 }
95}

Callers 1

bin.tsFile · 0.90

Calls 5

buildCommandFunction · 0.90
devCommandFunction · 0.90
initCommandFunction · 0.90
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected