Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Support alias names for bundled templates #49

Merged
merged 8 commits into from
Mar 12, 2018
Merged

Conversation

AliSoftware
Copy link
Collaborator

@AliSoftware AliSoftware commented Mar 7, 2018

This new feature allows us to create alias names for existing templates.

To create an alias template, simply create a text file named <alias_name>.alias whose first line just contains exactly the name of the template to point to.
Note: Any text after the first line of this *.alias files is ignored, so the next lines in the file can be used as comments if necessary.

Introducing android-java and swift4 template names

This feature allowed us to:

  • Rename the original template android to android-java, for better consistency with the new android-kotlin template
  • But still provide an alias to it via the name android, so that using -t android will still work (and not break the setup for existing users of gyro) and use the same template as if we used -t android-java explicitly
  • Also provide an alias named swift4 pointing to the template swift3, since the swift3 template is also compatible with Swift 4 so using the alias allows for a more logical name in the invocation of gyro.

This PR also closes #29

Terminal Screenshot showing the result of "gyro -l"

Allows to use `-t swift4` to use the `swift3` template with Swift4 code
Or `-t android-java` to use the `android` template and disambiguate with the new `android-kotlin` one
…android.alias

Inverse the roles of the original vs the alias for consistency with android.kotlin
@StevenWatremez
Copy link
Contributor

I have a question about alias for custom path. Do you want to authorize creating custom alias for custom templates or not ?

Actually we have two resolution methods for templates. Template.find_by_path(path) and Template.find_by_name(name), this last method implement alias resolution but not the first.

#
def self.find(template_param, fail_on_error = true)
template = if template_param.include?('/')
find_by_path(template_param, fail_on_error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_by_path take one argument and here you give two arguments. There is a mistake or non finish fail_on_error injection ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. fail_on_error was passed to find_by_path in early stage of dev of that feature, but I finally decided to move the handling of failure inside find directly and forgot to remove the parameter here. I'll fix it 👍

@AliSoftware
Copy link
Collaborator Author

I have a question about alias for custom path. Do you want to authorize creating custom alias for custom templates or not ?

I wondered about that but I don't see how that would work or be useful.
I mean, if you have custom templates anyway: they'll only work for your machine / your project because you'll have to have the custom templates you created on the machine to run gyro. So if that's templates that you created yourself, you can give them whatever name you want, right?

Copy link
Contributor

@StevenWatremez StevenWatremez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested gyro with ruby 2.0 and 2.4. Everything is ok for template generation in different configurations (by name and by path).

@AliSoftware AliSoftware merged commit 68234d0 into master Mar 12, 2018
@AliSoftware AliSoftware deleted the feature/alias branch March 12, 2018 09:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Folder Harmonisation
2 participants