krzysztofzablocki / SourceryPro-Feedback

Repository for discussing https://merowing.info/sourcery-pro/
12 stars 0 forks source link

[FEATURE] Arguments for templates in editor #11

Open jboulter11 opened 2 years ago

jboulter11 commented 2 years ago

Is your feature request related to a problem? Please describe. I'm trying to write a template which will generate code based on arguments, rather than existing code. It's going to be used in a codegen script to generate some basic classes but they need to be named based off the feature name, like ExampleClass.swift where Example is the feature name. However, I don't see a way to specify those args in the editor.

Describe the solution you'd like The ability to specify args for a template (probably in the right sidebar?)

Describe alternatives you've considered I've considered using a basic swift model source file to gen off of, but it would mean writing one to disk that just has a struct with my arg name. Would be better to just have an arg.

Additional context The template I'm developing will be triggered by a script and not only run in xcode or in the Sourcery Pro editor.

krzysztofzablocki commented 2 years ago

Xcode doesn't let you specify anything, for CLI run we already have arguments args, so don't really see anything else I could do here

do you want to have default values for Xcode extension run? so that you could have a single template for both CLI / Xcode

jboulter11 commented 2 years ago

The template I'm writing isn't for an xcode use case, it'll be run in the CLI once I'm done writing it, I'm using Sourcery Pro to develop it. I want to be able to specify args for the template when it's running inside Sourcery Pro for development so it doesn't just throw an error when I try to use {{ arguments.name }} or whatever the syntax is.

I suppose if it was run in xcode just using whatever args were saved to it in Sourcery Pro would be the ideal, or even just disabling a template with args in xcode if that gets the feature working faster.