File tree Expand file tree Collapse file tree 9 files changed +145
-52
lines changed
Expand file tree Collapse file tree 9 files changed +145
-52
lines changed Original file line number Diff line number Diff line change 5454 - name : Checkout
5555 uses : actions/checkout@v4
5656 - name : swift-format lint
57- run : make lint 2>&1 | Scripts/gh-workflow .swift
57+ run : make lint 2>&1 | Scripts/gh-format .swift
5858 shell : bash
Original file line number Diff line number Diff line change 88 swift package clean
99 rm -rf $(OUTPUD_DIR )
1010
11+ README.md : Playgrounds/README.playground/Contents.swift
12+ cat $< | ./Scripts/markdown.swift > $@
13+
1114# MARK: - format
1215
1316lint :
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*:
2+ # 🌌 SQLyra 🎼
3+
4+ [](https://github.com/Alexander-Ignition/SQLyra/actions/workflows/test.yml)
5+ [](https://developer.apple.com/swift)
6+ [](https://github.com/Alexander-Ignition/SQLyra/blob/master/LICENSE)
7+
8+ Swift SQLite wrapper.
9+
10+ [Documentation](https://alexander-ignition.github.io/SQLyra/documentation/sqlyra/)
11+
12+ - Note: this readme file is available as Xcode playground in Playgrounds/README.playground
13+
14+ ## Open
15+
16+ Create database in memory for reading and writing.
17+ */
18+ import SQLyra
19+
20+ let database = try Database . open (
21+ at: " new.db " ,
22+ options: [ . readwrite, . memory]
23+ )
24+ /*:
25+ ## Create table
26+
27+ Create table for contacts with fields `id` and `name`.
28+ */
29+ try database. execute (
30+ """
31+ CREATE TABLE contacts(
32+ id INT PRIMARY KEY NOT NULL,
33+ name TEXT
34+ );
35+ """
36+ )
37+ /*:
38+ ## Insert
39+
40+ Insert new contacts Paul and John.
41+ */
42+ try database. execute ( " INSERT INTO contacts (id, name) VALUES (1, 'Paul'); " )
43+ try database. execute ( " INSERT INTO contacts (id, name) VALUES (2, 'John'); " )
44+ /*:
45+ ## Select
46+
47+ Select all contacts from database.
48+ */
49+ struct Contact : Codable {
50+ let id : Int
51+ let name : String
52+ }
53+
54+ let contacts = try database. prepare ( " SELECT * FROM contacts; " ) . array ( decoding: Contact . self)
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" standalone =" yes" ?>
2+ <playground version =' 7.0' target-platform =' macos' swift-version =' 6' display-mode =' raw' buildActiveScheme =' true' importAppTypes =' true' />
Original file line number Diff line number Diff line change 77Swift SQLite wrapper.
88
99[ Documentation] ( https://alexander-ignition.github.io/SQLyra/documentation/sqlyra/ )
10+
11+ - Note: this readme file is available as Xcode playground in Playgrounds/README.playground
12+
13+ ## Open
14+
15+ Create database in memory for reading and writing.
16+ ``` swift
17+ import SQLyra
18+
19+ let database = try Database.open (
20+ at : " new.db" ,
21+ options : [.readwrite , .memory ]
22+ )
23+ ```
24+ ## Create table
25+
26+ Create table for contacts with fields ` id ` and ` name ` .
27+ ``` swift
28+ try database.execute (
29+ """
30+ CREATE TABLE contacts(
31+ id INT PRIMARY KEY NOT NULL,
32+ name TEXT
33+ );
34+ """
35+ )
36+ ```
37+ ## Insert
38+
39+ Insert new contacts Paul and John.
40+ ``` swift
41+ try database.execute (" INSERT INTO contacts (id, name) VALUES (1, 'Paul');" )
42+ try database.execute (" INSERT INTO contacts (id, name) VALUES (2, 'John');" )
43+ ```
44+ ## Select
45+
46+ Select all contacts from database.
47+ ``` swift
48+ struct Contact : Codable {
49+ let id: Int
50+ let name: String
51+ }
52+
53+ let contacts = try database.prepare (" SELECT * FROM contacts;" ).array (decoding : Contact.self )
54+ ```
Original file line number Diff line number Diff line change 11#!/usr/bin/env swift
22
3- // Workflow commands for GitHub Actions
4- // https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions
5- // Usage: xcrun swift-format lint --recursive --strict ./ 2>&1 | Scripts/gh-workflow.swift
6- // Test: echo "Sources/SQLime/SQLParameter.swift:23:1: warning: [TrailingWhitespace] remove trailing whitespace" | Scripts/gh-workflow.swift
3+ /*
4+ Usage: xcrun swift-format lint --recursive --strict ./ 2>&1 | Scripts/gh-format.swift
5+
6+ Test: echo "Sources/SQLime/SQLParameter.swift:23:1: warning: [TrailingWhitespace] remove trailing whitespace" | Scripts/gh-workflow.swift
7+
8+ Workflow commands for GitHub Actions
9+ https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions
10+ */
711
812let regex = #/(?<file>.+\.swift):(?<line>\d+):(?<column>\d+): (?<severity>.+): \[(?<title>.+)\] (?<message>.+)/#
913while let line = readLine ( ) {
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env swift
2+
3+ /*
4+ OVERVIEW: Convert Xcode Playground to markdown
5+
6+ USAGE: cat Playgrounds/Example.playground/Contents.swift | ./Scripts/markdown.swift
7+ */
8+
9+ enum TextBlock {
10+ case unknown, code, comment
11+ }
12+
13+ var block = TextBlock . unknown
14+
15+ while let line = readLine ( ) {
16+ if line. hasPrefix ( " /*") {
17+ if block == .code {
18+ print("```")
19+ }
20+ block = .comment
21+ } else if line.hasSuffix("*/" ) {
22+ print ( " ```swift " )
23+ block = . code
24+ } else if block == . comment {
25+ print ( line. drop ( while: \. isWhitespace) )
26+ } else {
27+ print ( line)
28+ }
29+ }
30+ if block == . code {
31+ print ( " ``` " )
32+ }
You can’t perform that action at this time.
0 commit comments