SwiftLI is a library aimed at writing command line displays in Swift in a SwiftUI-like manner, and was inspired by SwiftUI and Ignite.
Just as SwiftUI is a library that makes it easy to build a GUI in Swift, SwiftLI aims to make it easy to build a CLI in Swift.
The following environment is required to use this library.
The library includes a command line tool that allows you to verify its operation. Please use the following method to check the command line tool along with the source code.
- download this project file
- open a terminal
- Type the following command
cd <Path to this project>
make install
- Type the following command in a terminal
brew install kc-2001ms/tap/sclt
You can easily build a command line CUI by constructing your code as follows
import ArgumentParser
import SwiftLI
struct TextCommand: ParsableCommand {
static var configuration = CommandConfiguration(
commandName: "text",
abstract: "Display of Text structure",
discussion: """
Command to check the display of Text structure
""",
version: "0.0.2",
shouldDisplay: true,
helpNames: [.long, .short]
)
mutating func run() {
let group = Group {
Text("Text View")
.background(Color.white)
.forgroundColor(Color.blue)
.bold()
.newLine()
Group {
Group {
Text("Text.forgroundColor(_ color: Color)")
.forgroundColor(.red)
Spacer()
Text(".red")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Group {
Text("Text.backgroundColor(_ color: Color)")
.background(.red)
Spacer()
Text(".red")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Text("Text.bold()")
.bold()
.newLine()
Group {
Text("Text.bold(_ isActive: Bool)")
.bold(false)
Spacer()
Text("false")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Group {
Text("Text.fontWeight(_ weight: Weight)")
.fontWeight(.thin)
Spacer()
Text(".thin")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Text("Text.italic()")
.italic()
.newLine()
Group {
Text("Text.italic(_ isActive: Bool)")
.italic(false)
Spacer()
Text("false")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Text("Text.underline()")
.underline()
.newLine()
Group {
Text("Text.underline(_ isActive: Bool)")
.underline(false)
Spacer()
Text("false")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Group {
Text("Text.blink(_ style: BlinkStyle)")
.blink(.default)
Spacer()
Text(".default")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Text("Text.hidden()")
.hidden()
.newLine()
Group {
Text("Text.hidden(_ isActive: Bool)")
.hidden(false)
Spacer()
Text("false")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
Text("Text.strikethrough()")
.strikethrough()
.newLine()
Group {
Text("Text.strikethrough(_ isActive: Bool)")
.strikethrough(false)
Spacer()
Text("false")
.fontWeight(.thin)
.forgroundColor(.red)
}
.newLine()
}
}
group.render()
}
}
Add the following files to the Package.swift file for use. For more information, please visit swift.org.
dependencies: [
// Add this code
.package(url: "https://github.com/KC-2001MS/SwiftLI.git", from: "0.3.0"),
],
Swift-DocC is currently being implemented.
See CONTRIBUTING.md if you want to make a contribution.
If you would like to make a donation to this project, please click here. The money you give will be used to improve my programming skills and maintain the application.
Pay by PayPal