swift-ansi-picker

0.0.1

An interactive selection picker for Swift-based CLI applications.
rechsteiner/swift-ansi-picker

What's New

v0.0.1

2024-02-10T13:34:05Z

Swift ANSI Picker

This is a simple tool for adding interactive selection to CLI applications, designed to use with ANSI-supported terminals. This is a pretty small and focused package, with no third-party dependencies. I'm not planning on extending its functionality significantly, so if you need further customization, feel free to copy the code into your project and modify it as necessary. Alternatively, look into using a more feature-full package like ConsoleKit.

swift-ansi-picker.mov

Usage

Basic usage

import Picker

try choose(["Apple", "Banana", "Orange", "Watermelon"])
➜ Apple
  Banana
  Orange
  Watermelon

Customization

var picker = Picker()
picker.itemIndicator = ""
picker.itemColor = .darkGray
picker.selectionIndicator = ""
picker.selectionColor = .cyan

print("⏵ Choose your favorite fruit:")
print(try picker.choose(["Apple", "Banana", "Orange", "Watermelon"]))
⏵ Choose your favorite fruit:
  ● Apple
  ○ Banana
  ○ Orange
  ○ Watermelon

Installation

Add swift-ansi-picker to your Package.swift file:

.package(url: "https://github.com/rechsteiner/swift-ansi-picker.git", .exact(from: "0.0.1"))

Contributions

While I'm not planning on extending its functionality significantly, contributions for bug fixes and minor improvements are very welcome. Please use GitHub Issues to report bugs or suggest enhancements.

License

Swift ANSI Picker is available under the MIT license. See the LICENSE file for more info.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Apr 26 2024 20:13:12 GMT-0900 (Hawaii-Aleutian Daylight Time)