ts-to-zod icon indicating copy to clipboard operation
ts-to-zod copied to clipboard

add equivalent to --all cli flag to ignore ts-to-zod config at all

Open vladdcom opened this issue 11 months ago • 13 comments

Feature description

In cli prompt the program has option "Don't use the config" but i cannot use it through inline command ts-to-zod --none or ts-to-zod --config=none doesnt work

Input

ts-to-zod --config=none

Output

ts-to-zod ignore ts-to-zod config and use passed inline data

vladdcom avatar Feb 28 '24 10:02 vladdcom

Hello @vladdcom,

Do you mean that it would just ignore this prompt:

? You have multiple configs available in "ts-to-zod.config.js"
 What do you want? (Use arrow keys)
❯ Execute all configs (--all) 
  Execute "example" config (--config=example) 
  Execute "example/person" config (--config=example/person) 
  Execute "config" config (--config=config)
  Don't use the config 

and be the equivalent of selecting the last option?

tvillaren avatar Feb 28 '24 12:02 tvillaren

yeah, exactly the equivalent of selecting the last option

vladdcom avatar Feb 28 '24 13:02 vladdcom

In that case, you must add arguments to CLI call, right?

At least an input argument (and ideally an output otherwise your input will be overwritten). Maybe we should skip the config step altogether when an input is passed.

tvillaren avatar Feb 28 '24 13:02 tvillaren

per repo

yarn ts-to-zod --all -> use the ts-to-zod config yarn ts-to-zod --noneConfig src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts -> ignore the config, use inline params

"Don't use the config" in the prompt is working the same way

vladdcom avatar Feb 28 '24 13:02 vladdcom

In terms of developer experience, I'm wondering if we actually need the --noConfig flag.

Why not skip config when calling

yarn ts-to-zod src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts

?

My point being that all the information needed to perform the action is in the command. I think your request is very valid, but I feel that adding a new flag is not the best DevExp. What do you think?

tvillaren avatar Feb 28 '24 13:02 tvillaren

I have ts-to-zod config in my repo and if I run this command yarn ts-to-zod src/iDontTrustThisApi.ts src/nowIcanValidateEverything.ts

I'm gonna get into a interactive mode of the prompt. But I want to disable config by one command

vladdcom avatar Feb 28 '24 14:02 vladdcom

I'm gonna get into a interactive mode of the prompt. But I want to disable config by one command

Yes, I think I understand that. My point is that might be better to disable config if the command actually passes input and output arguments: no need to add a flag for that, it would be the logical behaviour to execute the generation directly.

tvillaren avatar Feb 28 '24 14:02 tvillaren

got it, the idea is good

vladdcom avatar Feb 28 '24 14:02 vladdcom

@tvillaren sounds good. If we implement this, so it would be breaking. Let's collect breaking changes such as this and the exit code 1 upon failure so we can combine those in a v4 release.

schiller-manuel avatar Feb 28 '24 16:02 schiller-manuel

Yep, had the same thought 😄 I don't have any permission on this repository, but I would be glad to help tag some features to track what could be added in a V4

tvillaren avatar Feb 28 '24 16:02 tvillaren

How can I tell the CLI to use the config file? It seems it needs me to duplicate the input-output files in the CLI.

aminya avatar May 26 '24 21:05 aminya

@aminya: if you have a ts-to-zod.config.js at the root of your project, the CLI should use it directly.

tvillaren avatar May 27 '24 08:05 tvillaren

@tvillaren I tried that in a mono-repo, but it did not work. Could you add more documentation on this? Also, the CLI doesn't have any indication of this happening despite using --verbose, or I could not find a --config settings for specifying the path.

aminya avatar May 28 '24 17:05 aminya