support both input and output

update readme

update readme
This commit is contained in:
Taegeun Moon 2022-12-01 12:37:48 +09:00
parent e955c47bd5
commit 927c29de4a
2 changed files with 13 additions and 8 deletions

View File

@ -92,8 +92,12 @@ Options:
[string] [default: "%s"]
--outputTemplate Template for mapping output or "restricted" type names
[string] [default: "%s__Output"]
--branded Emit property for branded type whose value is fullName
of the Message [boolean] [default: false]
--inputBranded Output property for branded type for "permissive"
types with fullName of the Message as its value
[boolean]
--outputBranded Output property for branded type for "restricted"
types with fullName of the Message as its value
[boolean]
```
### Example Usage

View File

@ -48,7 +48,8 @@ type GeneratorOptions = Protobuf.IParseOptions & Protobuf.IConversionOptions & {
includeComments?: boolean;
inputTemplate: string;
outputTemplate: string;
outputBranded: boolean;
inputBranded?: boolean;
outputBranded?: boolean;
}
class TextFormatter {
@ -272,9 +273,9 @@ function generatePermissiveMessageInterface(formatter: TextFormatter, messageTyp
}
formatter.writeLine(`'${oneof.name}'?: ${typeString};`);
}
// if (options.inputBranded) {
// formatTypeBrand(formatter, messageType);
// }
if (options.inputBranded) {
formatTypeBrand(formatter, messageType);
}
formatter.unindent();
formatter.writeLine('}');
}
@ -830,7 +831,7 @@ async function runScript() {
.string(['includeDirs', 'grpcLib'])
.normalize(['includeDirs', 'outDir'])
.array('includeDirs')
.boolean(['keepCase', 'defaults', 'arrays', 'objects', 'oneofs', 'json', 'verbose', 'includeComments', 'outputBranded'])
.boolean(['keepCase', 'defaults', 'arrays', 'objects', 'oneofs', 'json', 'verbose', 'includeComments', 'inputBranded', 'outputBranded'])
.string(['longs', 'enums', 'bytes', 'inputTemplate', 'outputTemplate'])
.default('keepCase', false)
.default('defaults', false)
@ -844,7 +845,6 @@ async function runScript() {
.default('bytes', 'Buffer')
.default('inputTemplate', `${templateStr}`)
.default('outputTemplate', `${templateStr}__Output`)
.default('outputBranded', false)
.coerce('longs', value => {
switch (value) {
case 'String': return String;
@ -884,6 +884,7 @@ async function runScript() {
grpcLib: 'The gRPC implementation library that these types will be used with',
inputTemplate: 'Template for mapping input or "permissive" type names',
outputTemplate: 'Template for mapping output or "restricted" type names',
inputBranded: 'Output property for branded type for "permissive" types with fullName of the Message as its value',
outputBranded: 'Output property for branded type for "restricted" types with fullName of the Message as its value',
}).demandOption(['outDir', 'grpcLib'])
.demand(1)