Add some code snippets
This commit is contained in:
+33
-1
@@ -1,6 +1,7 @@
|
||||
import { ArgumentParser } from "argparse";
|
||||
// tslint:disable-next-line:no-submodule-imports
|
||||
import colors = require("colors/safe");
|
||||
import * as fs from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
import { TsRepl } from "./tsrepl";
|
||||
@@ -11,6 +12,10 @@ export function main(originalArgs: readonly string[]): void {
|
||||
action: "storeTrue",
|
||||
help: "Print version and exit",
|
||||
});
|
||||
parser.addArgument("--init", {
|
||||
metavar: "FILEPATH",
|
||||
help: "Read initial TypeScript code from file",
|
||||
});
|
||||
|
||||
const maintainerGroup = parser.addArgumentGroup({
|
||||
title: "Maintainer options",
|
||||
@@ -33,7 +38,30 @@ export function main(originalArgs: readonly string[]): void {
|
||||
}
|
||||
|
||||
const imports = new Map<string, readonly string[]>([
|
||||
["@cosmwasm/sdk", ["types", "RestClient"]],
|
||||
["@cosmwasm/sdk", ["encodeSecp256k1Signature", "makeSignBytes", "marshalTx", "types", "RestClient"]],
|
||||
[
|
||||
"@iov/bcp",
|
||||
[
|
||||
"Address",
|
||||
"Algorithm",
|
||||
"ChainId",
|
||||
"Nonce",
|
||||
"PrehashType",
|
||||
"PubkeyBytes",
|
||||
"SendTransaction",
|
||||
"SignableBytes",
|
||||
"TokenTicker",
|
||||
"TransactionId",
|
||||
// block info
|
||||
"BlockInfoPending",
|
||||
"BlockInfoSucceeded",
|
||||
"BlockInfoFailed",
|
||||
"BlockInfo",
|
||||
"isBlockInfoPending",
|
||||
"isBlockInfoSucceeded",
|
||||
"isBlockInfoFailed",
|
||||
],
|
||||
],
|
||||
[
|
||||
"@iov/crypto",
|
||||
[
|
||||
@@ -134,6 +162,10 @@ export function main(originalArgs: readonly string[]): void {
|
||||
`;
|
||||
}
|
||||
|
||||
if (args.init) {
|
||||
init += fs.readFileSync(args.init, "utf8") + "\n";
|
||||
}
|
||||
|
||||
const tsconfigPath = join(__dirname, "..", "tsconfig_repl.json");
|
||||
const installationDir = join(__dirname, "..");
|
||||
new TsRepl(tsconfigPath, init, !!args.debug, installationDir).start().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user