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 {
|
||||
return `${toCSharpType(inp.type)} ${inp.name}`;
|
||||
}
|
||||
}).join(",");
|
||||
const genParam = () => a(2, `var param = new JsonArray(${fnc.inputs.map((e) => `JsonSerializer.SerializeToNode(${e.name})`).join(",")});`);
|
||||
}).join(", ");
|
||||
const genParam = () => a(2, `var param = new JsonArray(${fnc.inputs.map((e) => `JsonSerializer.SerializeToNode(${e.name})`).join(", ")});`);
|
||||
if (fnc.return) {
|
||||
if (fnc.return.type == "void") {
|
||||
a(1, `public async Task ${fnc.name}(${params}) {`);
|
||||
@ -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 {
|
||||
@ -10583,7 +10583,7 @@ var CSharpTarget = class extends CompileTarget {
|
||||
}
|
||||
}),
|
||||
"TContext ctx"
|
||||
].join(",");
|
||||
].join(", ");
|
||||
if (fnc.return) {
|
||||
if (fnc.return.type == "void") {
|
||||
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,
|
||||
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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user