Swift 命令行工具 -> Select 带箭头键和空格键

Swift Command Line Tool -> Select with arrow keys and spacebar

我正在使用 swift 构建命令行工具,我想让它们更具交互性以提供更好的用户体验。

我想知道是否可以为命令行工具构建一个 select 菜单,类似于 swift[= 中 firebase cli or the angular cli 中使用的菜单23=]。 我现在正在使用 swift argument parser,如果用户可以通过箭头键从菜单中的不同选项 select 和 select 使用 [=26],那就太好了=] bar.

Firebase CLI option selection with firebase init

据我所知,swift-argument-parser 目前无法做到这一点。这实际上在潜在项目的代码之夏创意列表中。

Swift ArgumentParser: Interactive mode

ArgumentParser provides a straightforward way to declare command-line interfaces in Swift, with the dual goals of making it (1) fast and easy to create (2) high-quality, user-friendly CLI tools. For this project, we would design and implement an interactive mode for tools built using ArgumentParser that prompts for any required arguments not given in the initial command. This work would need to allow partial initialization of types, and could include features like validation and auto-completion for user input.

https://www.swift.org/gsoc2021/

所以我相信它可能会在未来实现。