Skip to content

Commit 54f4976

Browse files
committed
Initial Commit
0 parents  commit 54f4976

File tree

8 files changed

+167
-0
lines changed

8 files changed

+167
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
DerivedData/
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.swiftpm

Package.swift

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:5.5
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: "CEExtensionKit",
8+
products: [
9+
// Products define the executables and libraries a package produces, and make them visible to other packages.
10+
.library(
11+
name: "CEExtensionKit",
12+
targets: ["CEExtensionKit"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
// .package(url: /* package url */, from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
21+
.target(
22+
name: "CEExtensionKit",
23+
dependencies: []),
24+
.testTarget(
25+
name: "CEExtensionKitTests",
26+
dependencies: ["CEExtensionKit"]),
27+
]
28+
)

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CEExtensionKit
2+
3+
A description of this package.
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// ExtensionAPI.swift
3+
//
4+
//
5+
// Created by Pavel Kasila on 27.03.22.
6+
//
7+
8+
import Foundation
9+
10+
/// A protocol to conform to for Extension API instance assigned to ``extensionId``
11+
public protocol ExtensionAPI {
12+
13+
var extensionId: String { get }
14+
15+
/// API to work with targets
16+
var targets: TargetsAPI { get }
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// ExtensionInterface.swift
3+
//
4+
//
5+
// Created by Pavel Kasila on 27.03.22.
6+
//
7+
8+
import Foundation
9+
10+
/// A protocol for extensions to conform to
11+
public protocol ExtensionInterface {
12+
13+
/// Initializes extension with API
14+
/// - Parameter withAPI: the API implementation itself
15+
init(withAPI api: ExtensionAPI) throws
16+
17+
}
18+
19+
open class ExtensionBuilder {
20+
21+
public init() {}
22+
23+
open func build() -> ExtensionInterface {
24+
fatalError("You should override ExtensionBuilder.build")
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// Target.swift
3+
//
4+
//
5+
// Created by Pavel Kasila on 27.03.22.
6+
//
7+
8+
import Foundation
9+
10+
/// This structure stores information about the target to be available in CodeEdit for running
11+
public struct Target: Identifiable {
12+
13+
/**
14+
* Initializes a target with parameters
15+
* - Parameter id: The unique identifier of the target set by the extension
16+
* - Parameter displayName: The name of the target to be displayed in the UI
17+
* - Parameter executable: The executable to launch inside the pseudo terminal
18+
* - Parameter args: an array of strings that is passed as the arguments to the underlying process
19+
* - Parameter environment: an array of environment variables to pass to the child process.
20+
* - Parameter execName: If provided, this is used as the Unix argv[0] parameter, otherwise, the executable is used as the args [0], this is used when the intent is to set a different process name than the file that backs it.
21+
*/
22+
public init(id: String, displayName: String,
23+
executable: String, args: [String] = [],
24+
environment: [String]? = nil, execName: String? = nil) {
25+
self.id = id
26+
self.displayName = displayName
27+
self.executable = executable
28+
self.args = args
29+
self.environment = environment
30+
self.execName = execName
31+
}
32+
33+
/// ``id`` is a unique identifier of the target set by the extension
34+
public var id: String
35+
36+
/// ``displayName`` is a name to be displayed in the UI to represent target
37+
public var displayName: String
38+
39+
/// ``executable`` is the executable to launch inside the pseudo terminal
40+
public var executable: String
41+
42+
/// ``args`` is an array of strings that is passed as the arguments to the underlying process
43+
public var args: [String] = []
44+
45+
/// ``environment`` is an array of environment variables to pass to the child process.
46+
public var environment: [String]?
47+
48+
/// ``execName`` If provided, this is used as the Unix argv[0] parameter, otherwise, the executable is used as the args [0], this is used when the intent is to set a different process name than the file that backs it.
49+
public var execName: String?
50+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// TargetsAPI.swift
3+
//
4+
//
5+
// Created by Pavel Kasila on 27.03.22.
6+
//
7+
8+
import Foundation
9+
10+
/// API for targets
11+
public protocol TargetsAPI {
12+
13+
/// Adds new target to the list
14+
/// - Parameter target: the target to be added to the list
15+
func add(target: Target)
16+
17+
/// Deletes a target from the list
18+
/// - Parameter target: the target to be removed from the list
19+
func delete(target: Target)
20+
21+
/// Clears all targets from the list
22+
func clear()
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import XCTest
2+
@testable import CEExtensionKit
3+
4+
final class CEExtensionKitTests: XCTestCase {
5+
func testExample() throws {
6+
// This is an example of a functional test case.
7+
// Use XCTAssert and related functions to verify your tests produce the correct
8+
// results.
9+
}
10+
}

0 commit comments

Comments
 (0)