evestera / json_typegen

Tools and libraries to create types for Rust, Kotlin, TypeScript and Python from JSON samples
https://typegen.vestera.as
Apache License 2.0
268 stars 26 forks source link

Typegen fail in batch. #41

Open jaynnn opened 6 months ago

jaynnn commented 6 months ago

The exact same code can be run in git bash, but an error will be reported in batch: json_typegen config/global_config.json -o code_template/rust/global_config.rs -n GlobalConfig --options "{ derives: 'Default, Debug, Clone, PartialEq, Serialize, Deserialize, Resource' }" error: The argument to 'derives' has to be a string literal, but remaining input was ''Default, Debug, Clone, PartialEq, Serialize, Deserialize, Resource' }' That really confuse me.

evestera commented 6 months ago

I think the issue here is that the option parsing only supports double quoted string literals ("I am a string") and not single quoted strings ('I am a string') for option values, so the invocation should be json_typegen config/global_config.json -o code_template/rust/global_config.rs -n GlobalConfig --options '{ derives: "Default, Debug, Clone, PartialEq, Serialize, Deserialize, Resource" }'

I might have a look at supporting single quoted string literals, but it might take a while before I get to that.