Interactive swift package init

Hello everyone,

I'm working on making swift package init interactive (as part of my GSoC-2023 project).


If you type swift package init and enter, a default library type project will be generated.

After reading this post Update to swift package init templates, I was inspired by it and thought it would be better to use swift package init as an interactive initialization command. Users can use arrow keys to select the template type and use enter to confirm, which is kinda easy.



Sorry for being a bit impulsive, I have implemented this feature in swiftPM's CLI(very early and simple implementation, for demostration purposes) and here is a video demo:

It's essentially ANSI escape code, and using c interop to achieve raw mode input (read the arrow keys).

At the same time, I want to introduce another interactivity, which is whether to include the test folder or not.

Please give me your opinions

Other than including test folder or not, I don't have a lot of ideas. What other options do you think are worth interacting with in the project init process that would make it faster and more convenient? Please let me know, thanks a lot! :yum:


It’s really appreciate the work being done on improving the CLI’s UX!

As for my suggestions, maybe plug-ins could also be selected through this interface? Further, for the tests it’d be better to provide a default, like Tests? (Y/n).

1 Like

Hi, as the gsoc organization admin for Swift I want to be clear about the fact that GSoC projects have not been accepted yet. You're of course free to work on the project on your own time, however this does not imply that this specific proposal/project will be accepted.

Accepted projects will be announced on May 4th: Spostamenti di Google Summer of Code 2023  |  Google Developers

It's great to continue like this, but I wanted to clarify the selection process, in order to avoid any harsh feelings or surprises after the selection process completes.

Thank you very much for the clarification. I'm sorry to post in such a hurry as if my proposal was accepted. I don't expect my proposal to be accepted for sure. The reason for this post is that after talking with @bitjammer, I realized that there might be some problems with the descriptions in the idea list, and my proposal is not optimal, so I wanted to ask everyone on the forum for their opinions. If my proposal is rejected, it is perfectly acceptable. If this post makes GSoC participants uncomfortable, I am very sorry. :pleading_face:

It's all good, please continue with threads -- I just felt the need to clarify in the thread that proposals have not been accepted yet. Carry on :slight_smile: :+1:

This looks cool! A few notes:

  • Feel free to take inspiration/borrow/steal stuff from Vapor's toolbox - GitHub - vapor/toolbox: Simplifies common command line tasks when using Vapor - that provides an interactive CLI to build Vapor applications from various templates and you can even provide your own
  • We need to ensure that whatever method we use for console interactivity works across different shells (bash/zsh) and all of Swift's supported platforms, (macOS, Linux and Windows)