Before submitting my proposal I came here to ask some important points related to the mechanically edit Package.swift project idea. During my research on this topic I faced with issues that will be better to discuss with you.
Imagine that we have a well-formed manifest file, a good example is the one that exists in the Swift Package Manager repository. It looks very well from the formatting point view. Moreover it has a nice targets list structure, common targets are separated from the test ones.
And now you want to add a new target using the CLI and here we are stuck with some problems:
- Indentation rules (new lines, spaces and their quantity) which will be applied to the newly created target expression
- Creation methods
For the case of indentation I see two options:
- Use indentation rules that are applied to the last target in the list. On my opinion this will work well for the most of the time
- Create a pre-defined identation rules and use them regardless of the existing manifest file style
A structure is also an interesting topic. If we modify manifest file like the one from Swift PM repository, it will be better to put newly created common target above all test ones to save existing structure. But I think it will be hard to came to some kind of general solution. Anyway I’m glad to hear you thoughts on this.
For creating a target instance we have two options: use a constructor or use a static method. For static method there is a practice to omit Target type name and use an implicit function call. Based on which rule do we select constructor over static method and omit Target type in the method call?