Add "targets" command
This commit is contained in:
parent
49425cab39
commit
983ba1f870
15
lib/jrpc.js
15
lib/jrpc.js
@ -10524,8 +10524,8 @@ var CSharpTarget = class extends CompileTarget {
|
|||||||
} else {
|
} else {
|
||||||
return `${toCSharpType(inp.type)} ${inp.name}`;
|
return `${toCSharpType(inp.type)} ${inp.name}`;
|
||||||
}
|
}
|
||||||
}).join(",");
|
}).join(", ");
|
||||||
const genParam = () => a(2, `var param = new JsonArray(${fnc.inputs.map((e) => `JsonSerializer.SerializeToNode(${e.name})`).join(",")});`);
|
const genParam = () => a(2, `var param = new JsonArray(${fnc.inputs.map((e) => `JsonSerializer.SerializeToNode(${e.name})`).join(", ")});`);
|
||||||
if (fnc.return) {
|
if (fnc.return) {
|
||||||
if (fnc.return.type == "void") {
|
if (fnc.return.type == "void") {
|
||||||
a(1, `public async Task ${fnc.name}(${params}) {`);
|
a(1, `public async Task ${fnc.name}(${params}) {`);
|
||||||
@ -10567,7 +10567,7 @@ var CSharpTarget = class extends CompileTarget {
|
|||||||
a(0, ``);
|
a(0, ``);
|
||||||
a(0, `public abstract class ${definition.name}Server<TContext> : JRpcService<TContext> {`);
|
a(0, `public abstract class ${definition.name}Server<TContext> : JRpcService<TContext> {`);
|
||||||
a(0, ``);
|
a(0, ``);
|
||||||
a(1, `public ${definition.name}Server(JRpcClient client) {`);
|
a(1, `public ${definition.name}Server() {`);
|
||||||
for (const fnc of definition.functions) {
|
for (const fnc of definition.functions) {
|
||||||
a(2, `this.RegisterFunction("${fnc.name}");`);
|
a(2, `this.RegisterFunction("${fnc.name}");`);
|
||||||
}
|
}
|
||||||
@ -10575,7 +10575,7 @@ var CSharpTarget = class extends CompileTarget {
|
|||||||
a(0, ``);
|
a(0, ``);
|
||||||
for (const fnc of definition.functions) {
|
for (const fnc of definition.functions) {
|
||||||
let params = [
|
let params = [
|
||||||
fnc.inputs.map((inp) => {
|
...fnc.inputs.map((inp) => {
|
||||||
if (inp.array) {
|
if (inp.array) {
|
||||||
return `List<${toCSharpType(inp.type)}> ${inp.name}`;
|
return `List<${toCSharpType(inp.type)}> ${inp.name}`;
|
||||||
} else {
|
} else {
|
||||||
@ -10583,7 +10583,7 @@ var CSharpTarget = class extends CompileTarget {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
"TContext ctx"
|
"TContext ctx"
|
||||||
].join(",");
|
].join(", ");
|
||||||
if (fnc.return) {
|
if (fnc.return) {
|
||||||
if (fnc.return.type == "void") {
|
if (fnc.return.type == "void") {
|
||||||
a(1, `public abstract Task ${fnc.name}(${params});`);
|
a(1, `public abstract Task ${fnc.name}(${params});`);
|
||||||
@ -10815,6 +10815,11 @@ yargs_default(hideBin(process.argv)).version("1.0.0").command("compile <input>",
|
|||||||
targets: argv.output,
|
targets: argv.output,
|
||||||
emitDefinitions: argv.definition
|
emitDefinitions: argv.definition
|
||||||
});
|
});
|
||||||
|
}).command("targets", "List all targets", (yargs) => yargs, () => {
|
||||||
|
console.log("Targets:");
|
||||||
|
Targets.forEach((__dirname3, target) => {
|
||||||
|
console.log(" " + target);
|
||||||
|
});
|
||||||
}).option("verbose", {
|
}).option("verbose", {
|
||||||
alias: "v",
|
alias: "v",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hibas123/jrpcgen",
|
"name": "@hibas123/jrpcgen",
|
||||||
"version": "1.0.13",
|
"version": "1.0.14",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"packageManager": "yarn@3.1.1",
|
"packageManager": "yarn@3.1.1",
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import yargs from "yargs";
|
import yargs from "yargs";
|
||||||
import { hideBin } from "yargs/helpers";
|
import { hideBin } from "yargs/helpers";
|
||||||
import startCompile, { Target } from "./process";
|
import startCompile, { Target, Targets } from "./process";
|
||||||
|
|
||||||
import dbg from "debug";
|
import dbg from "debug";
|
||||||
const log = dbg("app");
|
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", {
|
.option("verbose", {
|
||||||
alias: "v",
|
alias: "v",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
@ -16,12 +16,13 @@ class CatchedError extends Error {}
|
|||||||
|
|
||||||
const log = dbg("app");
|
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-esm", ESMTypescriptTarget);
|
||||||
Targets.set("ts-node", NodeJSTypescriptTarget);
|
Targets.set("ts-node", NodeJSTypescriptTarget);
|
||||||
Targets.set("c#", CSharpTarget as typeof CompileTarget);
|
Targets.set("c#", CSharpTarget as typeof CompileTarget);
|
||||||
|
|
||||||
|
|
||||||
function indexToLineAndCol(src: string, index: number) {
|
function indexToLineAndCol(src: string, index: number) {
|
||||||
let line = 1;
|
let line = 1;
|
||||||
let col = 1;
|
let col = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user