sourcecred/src/cli/main.js
William Chargin ff2d4f2fd8
cli: add main, sourcecred, and help (#741)
Summary:
This commit includes a minimal usage of an actual CLI application. It
provides the `help` command and no actual functionality.

Test Plan:
Unit tests added, with full coverage. To see it in action, first run
`yarn backend`, then run `node bin/cli.js help`.

wchargin-branch: cli-beginnings
2018-09-02 15:53:24 -07:00

23 lines
572 B
JavaScript

// @flow
import {handlingErrors} from "./command";
import sourcecred from "./sourcecred";
require("../tools/entry");
export default function main(): Promise<void> {
return handlingErrors(sourcecred)(process.argv.slice(2), {
out: (x) => console.log(x),
err: (x) => console.error(x),
}).then((exitCode) => {
process.exitCode = exitCode;
});
}
// Only run in the Webpack bundle, not as a Node module (during tests).
/* istanbul ignore next */
/*:: declare var __webpack_require__: mixed; */
if (typeof __webpack_require__ !== "undefined") {
main();
}