Add "targets" command

This commit is contained in:
K35 2022-01-07 08:45:08 +00:00
parent 49425cab39
commit 983ba1f870
4 changed files with 20 additions and 8 deletions

View File

@ -10567,7 +10567,7 @@ var CSharpTarget = class extends CompileTarget {
a(0, ``);
a(0, `public abstract class ${definition.name}Server<TContext> : JRpcService<TContext> {`);
a(0, ``);
a(1, `public ${definition.name}Server(JRpcClient client) {`);
a(1, `public ${definition.name}Server() {`);
for (const fnc of definition.functions) {
a(2, `this.RegisterFunction("${fnc.name}");`);
}
@ -10575,7 +10575,7 @@ var CSharpTarget = class extends CompileTarget {
a(0, ``);
for (const fnc of definition.functions) {
let params = [
fnc.inputs.map((inp) => {
...fnc.inputs.map((inp) => {
if (inp.array) {
return `List<${toCSharpType(inp.type)}> ${inp.name}`;
} else {
@ -10815,6 +10815,11 @@ yargs_default(hideBin(process.argv)).version("1.0.0").command("compile <input>",
targets: argv.output,
emitDefinitions: argv.definition
});
}).command("targets", "List all targets", (yargs) => yargs, () => {
console.log("Targets:");
Targets.forEach((__dirname3, target) => {
console.log(" " + target);
});
}).option("verbose", {
alias: "v",
type: "boolean",

View File

@ -1,6 +1,6 @@
{
"name": "@hibas123/jrpcgen",
"version": "1.0.13",
"version": "1.0.14",
"main": "lib/index.js",
"license": "MIT",
"packageManager": "yarn@3.1.1",

View File

@ -2,7 +2,7 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import startCompile, { Target } from "./process";
import startCompile, { Target, Targets } from "./process";
import dbg from "debug";
const log = dbg("app");
@ -54,6 +54,12 @@ yargs(hideBin(process.argv))
})
}
)
.command("targets", "List all targets", (yargs)=>yargs, ()=>{
console.log("Targets:")
Targets.forEach((__dirname, target) => {
console.log(" " + target);
})
})
.option("verbose", {
alias: "v",
type: "boolean",

View File

@ -16,12 +16,13 @@ class CatchedError extends Error {}
const log = dbg("app");
const Targets = new Map<string, typeof CompileTarget>();
export const Targets = new Map<string, typeof CompileTarget>();
Targets.set("ts-esm", ESMTypescriptTarget);
Targets.set("ts-node", NodeJSTypescriptTarget);
Targets.set("c#", CSharpTarget as typeof CompileTarget);
function indexToLineAndCol(src: string, index: number) {
let line = 1;
let col = 1;