Skip to content

Commit

Permalink
Split ConsoleKit into two functional targets (#192)
Browse files Browse the repository at this point in the history
* Split ConsoleKit into two functional targets - one for terminal interaction, one for command handling, plus an umbrella for compatibility. Also update README, and docs images. Clean up several bits of code.
* Apply some of the lessons learned from apple/swift-argument-parser#590, pretty much just for the hell of it. Deprecate `ConsoleErrror`.
* Readme cleanup
* Make the levenshteinDistance method noticeably more efficient.

---------

Co-authored-by: Mahdi Bahrami <[email protected]>
Co-authored-by: Tim Condon <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2023
1 parent 2e3e205 commit 0bd6673
Show file tree
Hide file tree
Showing 80 changed files with 475 additions and 453 deletions.
5 changes: 0 additions & 5 deletions .github/CONTRIBUTING.md

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
secrets: inherit
with:
package_name: console-kit
modules: ConsoleKit
pathsToInvalidate: /consolekit/*
modules: ConsoleKit ConsoleKitTerminal ConsoleKitCommands
pathsToInvalidate: /consolekit/* /consolekitterminal/* /consolekitcommands/*
74 changes: 51 additions & 23 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,62 @@ let package = Package(
],
products: [
.library(name: "ConsoleKit", targets: ["ConsoleKit"]),
.library(name: "ConsoleKitTerminal", targets: ["ConsoleKitTerminal"]),
.library(name: "ConsoleKitCommands", targets: ["ConsoleKitCommands"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.56.0"),
],
targets: [
.target(name: "ConsoleKit", dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio")
]),
.testTarget(name: "ConsoleKitTests", dependencies: [
.target(name: "ConsoleKit"),
]),
.testTarget(name: "AsyncConsoleKitTests", dependencies: [
.target(name: "ConsoleKit"),
]),
.testTarget(name: "ConsoleKitPerformanceTests", dependencies: [
.target(name: "ConsoleKit")
]),
.executableTarget(name: "ConsoleKitExample", dependencies: [
.target(name: "ConsoleKit"),
]),
.executableTarget(name: "ConsoleKitAsyncExample", dependencies: [
.target(name: "ConsoleKit")
]),
.executableTarget(name: "ConsoleLoggerExample", dependencies: [
.target(name: "ConsoleKit"),
.product(name: "Logging", package: "swift-log")
])
.target(
name: "ConsoleKit",
dependencies: [
.target(name: "ConsoleKitCommands"),
.target(name: "ConsoleKitTerminal"),
]
),
.target(
name: "ConsoleKitCommands",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.target(name: "ConsoleKitTerminal"),
]
),
.target(
name: "ConsoleKitTerminal",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
]
),
.testTarget(
name: "ConsoleKitTests",
dependencies: [.target(name: "ConsoleKit")]
),
.testTarget(
name: "AsyncConsoleKitTests",
dependencies: [.target(name: "ConsoleKit")]
),
.testTarget(
name: "ConsoleKitPerformanceTests",
dependencies: [.target(name: "ConsoleKit")]
),
.executableTarget(
name: "ConsoleKitExample",
dependencies: [.target(name: "ConsoleKit")]
),
.executableTarget(
name: "ConsoleKitAsyncExample",
dependencies: [.target(name: "ConsoleKit")]
),
.executableTarget(
name: "ConsoleLoggerExample",
dependencies: [
.target(name: "ConsoleKit"),
.product(name: "Logging", package: "swift-log"),
]
),
]
)
96 changes: 68 additions & 28 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
// swift-tools-version:5.9
import PackageDescription

let swiftSettings: [PackageDescription.SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("DisableOutwardActorInference"),
]

let package = Package(
name: "console-kit",
platforms: [
Expand All @@ -11,39 +19,71 @@ let package = Package(
],
products: [
.library(name: "ConsoleKit", targets: ["ConsoleKit"]),
.library(name: "ConsoleKitTerminal", targets: ["ConsoleKitTerminal"]),
.library(name: "ConsoleKitCommands", targets: ["ConsoleKitCommands"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.56.0"),
],
targets: [
.target(name: "ConsoleKit", dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio")
], swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("ConciseMagicFile"),
]),
.testTarget(name: "ConsoleKitTests", dependencies: [
.target(name: "ConsoleKit"),
], swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]),
.testTarget(name: "AsyncConsoleKitTests", dependencies: [
.target(name: "ConsoleKit"),
], swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]),
.testTarget(name: "ConsoleKitPerformanceTests", dependencies: [
.target(name: "ConsoleKit")
], swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]),
.executableTarget(name: "ConsoleKitExample", dependencies: [
.target(name: "ConsoleKit"),
], swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]),
.executableTarget(name: "ConsoleKitAsyncExample", dependencies: [
.target(name: "ConsoleKit")
], swiftSettings: [.enableExperimentalFeature("StrictConcurrency=complete")]),
.executableTarget(name: "ConsoleLoggerExample", dependencies: [
.target(name: "ConsoleKit"),
.product(name: "Logging", package: "swift-log")
])
.target(
name: "ConsoleKit",
dependencies: [
.target(name: "ConsoleKitCommands"),
.target(name: "ConsoleKitTerminal"),
],
swiftSettings: swiftSettings
),
.target(
name: "ConsoleKitCommands",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
.target(name: "ConsoleKitTerminal"),
],
swiftSettings: swiftSettings
),
.target(
name: "ConsoleKitTerminal",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOConcurrencyHelpers", package: "swift-nio"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "ConsoleKitTests",
dependencies: [.target(name: "ConsoleKit")],
swiftSettings: swiftSettings
),
.testTarget(
name: "AsyncConsoleKitTests",
dependencies: [.target(name: "ConsoleKit")],
swiftSettings: swiftSettings
),
.testTarget(
name: "ConsoleKitPerformanceTests",
dependencies: [.target(name: "ConsoleKit")],
swiftSettings: swiftSettings
),
.executableTarget(
name: "ConsoleKitExample",
dependencies: [.target(name: "ConsoleKit")],
swiftSettings: swiftSettings
),
.executableTarget(
name: "ConsoleKitAsyncExample",
dependencies: [.target(name: "ConsoleKit")],
swiftSettings: swiftSettings
),
.executableTarget(
name: "ConsoleLoggerExample",
dependencies: [
.target(name: "ConsoleKit"),
.product(name: "Logging", package: "swift-log"),
],
swiftSettings: swiftSettings
),
]
)
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/1130717/261745577-198fc7fb-5d7c-4702-ae46-f7abbcadf2a0.png">
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/1130717/261745583-90f95eb5-fe6f-4e1b-8fe1-268ff889199d.png">
<img src="https://user-images.githubusercontent.com/1130717/261745583-90f95eb5-fe6f-4e1b-8fe1-268ff889199d.png" height="96" alt="ConsoleKit">
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/console-kit/assets/1130717/3c06f3a4-8edb-4341-8b50-eb6aacb47e0b">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/console-kit/assets/1130717/3bb2255d-f564-43d2-a9e9-386420005adf">
<img src="https://github.com/vapor/console-kit/assets/1130717/3bb2255d-f564-43d2-a9e9-386420005adf" height="96" alt="ConsoleKit">
</picture>
<br>
<br>
<a href="https://docs.vapor.codes/4.0/"><img src="https://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation"></a>
<a href="https://discord.gg/vapor"><img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/console-kit/actions/workflows/test.yml"><img src="https://github.com/vapor/console-kit/actions/workflows/test.yml/badge.svg" alt="Continuous Integration"></a>
<a href="https://swift.org"><img src="https://img.shields.io/badge/swift-5.6-brightgreen.svg" alt="Swift 5.6"></a>
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/console-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/console-kit/test.yml?event=push&style=plastic&logo=github&label=test&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/gh/vapor/console-kit"><img src="https://img.shields.io/codecov/c/gh/vapor/console-kit?style=plastic&logo=codecov&label=Codecov&token=FroD9hgbSC"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift57up.svg" alt="Swift 5.7+"></a>
</p>
<br>
47 changes: 0 additions & 47 deletions Sources/ConsoleKit/Command/Utilities.swift

This file was deleted.

1 change: 0 additions & 1 deletion Sources/ConsoleKit/Docs.docc/images/article.svg

This file was deleted.

53 changes: 17 additions & 36 deletions Sources/ConsoleKit/Docs.docc/images/vapor-consolekit-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions Sources/ConsoleKit/Docs.docc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
@TitleHeading(Package)
}

ConsoleKit provides utilities for interacting with a console via a Swift application. It provides:
Utilities for interacting with a terminal and the commandline in a Swift application.

* A ``Command`` type for writing commands with arguments and flags
* Utilities for sending and receiving text to a terminal
* A [Swift Log](https://github.com/apple/swift-log) implementation for a ``Logger`` that outputs to the console

> Note: At this time, the argument handling capabilities of ConsoleKit are considered obsolete; using [ArgumentParser](https://github.com/apple/swift-argument-parser.git) instead is recommended where practical.
`ConsoleKit` is an umbrella module, exporting [ConsoleKitTerminal](./ConsoleKitTerminal) and [ConsoleKitCommands](./ConsoleKitCommands). It has no separate functionality of its own.
Loading

0 comments on commit 0bd6673

Please sign in to comment.