diff --git a/package.json b/package.json index 66b82ac..1017fe8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hibas123/jrpcgen", - "version": "1.2.0", + "version": "1.2.2", "main": "lib/index.js", "license": "MIT", "packageManager": "yarn@3.1.1", diff --git a/src/index.ts b/src/index.ts index 4854cf9..422cd92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,13 +4,15 @@ import yargs from "yargs"; import { hideBin } from "yargs/helpers"; import startCompile, { Target, Targets } from "./process"; +const pkg = require("../package.json"); + import dbg from "debug"; const log = dbg("app"); dbg.disable(); yargs(hideBin(process.argv)) - .version("1.0.0") + .version(pkg.version) .command( "compile ", "Compile source", diff --git a/src/targets/rust.ts b/src/targets/rust.ts index 622eb12..29f3bc1 100644 --- a/src/targets/rust.ts +++ b/src/targets/rust.ts @@ -71,6 +71,7 @@ export class RustTarget extends CompileTarget<{ rust_crate: string }> { a(0, `#[derive(Clone, Debug, Serialize, Deserialize)]`); a(0, `pub struct ${definition.name} {`); for (const field of definition.fields) { + a(1, `#[allow(non_snake_case)]`); if (field.array) { a(1, `pub ${field.name}: Vec<${toRustType(field.type)}>,`); } else if (field.map) { @@ -142,6 +143,7 @@ export class RustTarget extends CompileTarget<{ rust_crate: string }> { let ret = fnc.return ? typeToRust(fnc.return.type, fnc.return.array) : "()"; + a(1, `#[allow(non_snake_case)]`); a(1, `pub async fn ${fnc.name}(&self, ${params}) -> Result<${ret}> {`); a(2, `let l_req = JRPCRequest {`); a(3, `jsonrpc: "2.0".to_owned(),`); @@ -206,6 +208,7 @@ export class RustTarget extends CompileTarget<{ rust_crate: string }> { let ret = fnc.return ? typeToRust(fnc.return.type, fnc.return.array) : "()"; + a(1, `#[allow(non_snake_case)]`); a(1, `async fn ${fnc.name}(&self, ${params}) -> Result<${ret}>;`); } a(0, `}`); @@ -235,6 +238,7 @@ export class RustTarget extends CompileTarget<{ rust_crate: string }> { a(1, `fn get_id(&self) -> String { "${definition.name}".to_owned() }`); a(0, ``); + a(1, `#[allow(non_snake_case)]`); a( 1, `async fn handle(&self, msg: &JRPCRequest, function: &str) -> Result<(bool, Value)> {` diff --git a/templates/Rust/Cargo.toml b/templates/Rust/Cargo.toml index a4551e2..e150e28 100644 --- a/templates/Rust/Cargo.toml +++ b/templates/Rust/Cargo.toml @@ -12,5 +12,4 @@ serde_json = "1.0.88" nanoid = "0.4.0" tokio = { version = "1.22.0", features = ["full"] } log = "0.4.17" -simple_logger = { version = "4.0.0", features = ["threads", "colored", "timestamps", "stderr"] } async-trait = "0.1.59"