cli2: add skeleton of new CLI (#1809)

Summary:
This patch creates a new binary, `./bin/sc2`, which will be the home for
a rewrite of the CLI intended to implement an instance system. See:
<https://discourse.sourcecred.io/t/sourcecred-instance-system/244>

Paired with @decentralion.

Test Plan:
Run `yarn backend && node ./bin/sc2.js`, which should nicely fail with a
“not yet implemented” message.

wchargin-branch: cli2-skeleton
This commit is contained in:
William Chargin 2020-05-28 18:33:04 -07:00 committed by GitHub
parent 97da2ae077
commit 0449c9ea37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 0 deletions

View File

@ -30,6 +30,7 @@ module.exports = {
// point within the build directory. // point within the build directory.
backendEntryPoints: { backendEntryPoints: {
sourcecred: resolveApp("src/cli/main.js"), sourcecred: resolveApp("src/cli/main.js"),
sc2: resolveApp("src/cli2/main.js"),
// //
generateGithubGraphqlFlowTypes: resolveApp( generateGithubGraphqlFlowTypes: resolveApp(
"src/plugins/github/bin/generateGraphqlFlowTypes.js" "src/plugins/github/bin/generateGraphqlFlowTypes.js"

3
src/cli2/command.js Normal file
View File

@ -0,0 +1,3 @@
// @flow
export * from "../cli/command";

23
src/cli2/main.js Normal file
View File

@ -0,0 +1,23 @@
// @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; */
// eslint-disable-next-line camelcase
if (typeof __webpack_require__ !== "undefined") {
main();
}

10
src/cli2/sourcecred.js Normal file
View File

@ -0,0 +1,10 @@
// @flow
import type {Command} from "./command";
const sourcecred: Command = async (args, std) => {
std.err("SourceCred CLI v2 not yet implemented");
return 1;
};
export default sourcecred;