Skip to content

Commit 46ed976

Browse files
Move the LogParser example app outside of the library’s directory
I want it to be easy for people to create a script that uses the LogParser library. The easiest thing I can think of is to be able to just copy and paste the existing example app and then make modifications to it. This isn’t very easy with the current structure, since the example app’s code and build config is a bit intertwined with that of the LogParser library. By putting the example app in a separate directory, we can make a copy of it by just duplicating the entire directory.
1 parent 86b3a9f commit 46ed976

File tree

8 files changed

+40
-25
lines changed

8 files changed

+40
-25
lines changed

.github/workflows/check.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ jobs:
4848

4949
check-log-parser:
5050
runs-on: macos-latest
51-
defaults:
52-
run:
53-
working-directory: Tools/LogParser
5451
steps:
5552
- uses: actions/checkout@v2
5653
with:
5754
submodules: recursive
5855

5956
- name: Run LogParser tests
6057
run: swift test
61-
- name: Build LogParser command-line example app
62-
run: swift build --target CommandLineExample
58+
working-directory: Tools/LogParser
59+
60+
- name: Build LogParserExample app
61+
run: swift build
62+
working-directory: Tools/LogParserExample

Tools/LogParser/Package.swift

+1-15
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ let package = Package(
1111
products: [
1212
.library(
1313
name: "LogParser",
14-
targets: ["LogParser"]),
15-
.executable(
16-
name: "CommandLineExample",
17-
targets: ["CommandLineExample"])
18-
],
19-
dependencies: [
20-
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0")
14+
targets: ["LogParser"])
2115
],
2216
targets: [
2317
.target(
@@ -26,14 +20,6 @@ let package = Package(
2620
.testTarget(
2721
name: "LogParserTests",
2822
dependencies: ["LogParser"]
29-
),
30-
.executableTarget(
31-
name: "CommandLineExample",
32-
dependencies: [
33-
"LogParser",
34-
.product(name: "ArgumentParser", package: "swift-argument-parser")
35-
],
36-
path: "Examples/CommandLineExample/Sources"
3723
)
3824
]
3925
)

Tools/LogParser/README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,4 @@
22

33
A package for parsing the log output of the Ably Asset Tracking Swift SDKs and their example apps.
44

5-
There is an example command-line app in [`Examples/CommandLineExample`](Examples/CommandLineExample) which demonstrates how to use the library. You can run it on an example log file by running the following command from the current directory:
6-
7-
```bash
8-
swift run CommandLineExample Examples/CommandLineExample/example.txt
9-
```
5+
There is an example command-line app in [`../LogParserExample`](../LogParserExample) which demonstrates how to use the library.

Tools/LogParserExample/Package.swift

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version: 5.7
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "LogParserExample",
8+
platforms: [
9+
.macOS(.v12)
10+
],
11+
dependencies: [
12+
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.0"),
13+
.package(path: "../LogParser")
14+
],
15+
targets: [
16+
.executableTarget(
17+
name: "LogParserExample",
18+
dependencies: [
19+
.product(name: "LogParser", package: "LogParser"),
20+
.product(name: "ArgumentParser", package: "swift-argument-parser")
21+
]
22+
),
23+
]
24+
)

Tools/LogParserExample/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# LogParserExample
2+
3+
An example command-line app which demonstrates how to use the [LogParser library](../LogParser).
4+
5+
You can run it on an example log file by running the following command from the current directory:
6+
7+
```bash
8+
swift run LogParserExample example.txt
9+
```

0 commit comments

Comments
 (0)