-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
041a714
commit ebde410
Showing
4 changed files
with
81 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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,17 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
|
||
esmRequire = require('esm')(module); | ||
const main = esmRequire('../lib/main.js').default; | ||
const progname = process.argv[1]; | ||
|
||
process.on('SIGINT', () => process.exit(-1)); | ||
|
||
main(path.basename(process.argv[1]), process.argv.splice(2)).then( | ||
res => res === undefined || process.exit(res), | ||
rej => { | ||
console.error(`${progname}: error:`, rej); | ||
process.exit(1); | ||
}, | ||
); |
This file contains 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,47 @@ | ||
import chalk from 'chalk'; | ||
import parseArgs from 'minimist'; | ||
|
||
const VERSION = 'Agoric 0.1.0'; | ||
|
||
const main = async (progname, rawArgs) => { | ||
const { _: args, ...opts } = parseArgs(rawArgs, { | ||
boolean: ['version', 'help'], | ||
stopEarly: true, | ||
}); | ||
|
||
const usage = status => { | ||
if (status) { | ||
console.error(`Type '${progname} --help' for more information.`); | ||
return status; | ||
} | ||
console.log(`\ | ||
Usage: ${progname} [command] [...args] | ||
help display this help and exit | ||
`); | ||
return 0; | ||
}; | ||
|
||
if (opts.version) { | ||
console.log(VERSION); | ||
return 0; | ||
} | ||
|
||
if (opts.help) { | ||
return usage(0); | ||
} | ||
|
||
const cmd = args[0]; | ||
switch (cmd) { | ||
case undefined: | ||
console.error(`${progname}: error: you must specify a COMMAND`); | ||
return usage(1); | ||
case 'help': | ||
return usage(0); | ||
default: | ||
console.error(`${progname}: error: unrecognized COMMAND ${cmd}`); | ||
return usage(1); | ||
} | ||
}; | ||
|
||
export default main; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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