2018-07-06 11:13:38 +01:00
|
|
|
/**
|
2018-09-04 10:05:04 +01:00
|
|
|
* Create a REPL server for chef
|
|
|
|
*
|
2018-07-06 11:13:38 +01:00
|
|
|
*
|
2018-09-04 10:05:04 +01:00
|
|
|
* @author d98762656 [d98762625@gmail.com]
|
|
|
|
* @copyright Crown Copyright 2018
|
|
|
|
* @license Apache-2.0
|
2018-07-06 11:13:38 +01:00
|
|
|
*/
|
|
|
|
|
2018-09-04 10:05:04 +01:00
|
|
|
import { operations } from "./index";
|
|
|
|
import chef from "./index";
|
|
|
|
import { decapitalise } from "./apiUtils";
|
|
|
|
import repl from "repl";
|
|
|
|
import "babel-polyfill";
|
2018-07-06 11:13:38 +01:00
|
|
|
|
2018-09-04 10:05:04 +01:00
|
|
|
/*eslint no-console: ["off"] */
|
2018-07-06 11:13:38 +01:00
|
|
|
|
2018-09-21 12:24:34 +01:00
|
|
|
console.log(`
|
|
|
|
______ __ ________ ____
|
|
|
|
/ ____/_ __/ /_ ___ _____/ ____/ /_ ___ / __/
|
|
|
|
/ / / / / / __ \\/ _ \\/ ___/ / / __ \\/ _ \\/ /_
|
|
|
|
/ /___/ /_/ / /_/ / __/ / / /___/ / / / __/ __/
|
|
|
|
\\____/\\__, /_.___/\\___/_/ \\____/_/ /_/\\___/_/
|
|
|
|
/____/
|
|
|
|
|
|
|
|
`);
|
2018-07-06 11:13:38 +01:00
|
|
|
const replServer = repl.start({
|
2018-09-04 10:05:04 +01:00
|
|
|
prompt: "chef > ",
|
|
|
|
});
|
|
|
|
|
|
|
|
operations.forEach((op) => {
|
|
|
|
replServer.context[decapitalise(op.opName)] = op;
|
2018-07-06 11:13:38 +01:00
|
|
|
});
|
|
|
|
|
2018-09-04 10:05:04 +01:00
|
|
|
replServer.context.help = chef.help;
|
|
|
|
replServer.context.bake = chef.bake;
|