-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 54f4976
Showing
8 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
/*.xcodeproj | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.swiftpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// swift-tools-version:5.5 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "CEExtensionKit", | ||
products: [ | ||
// Products define the executables and libraries a package produces, and make them visible to other packages. | ||
.library( | ||
name: "CEExtensionKit", | ||
targets: ["CEExtensionKit"]), | ||
], | ||
dependencies: [ | ||
// Dependencies declare other packages that this package depends on. | ||
// .package(url: /* package url */, from: "1.0.0"), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package. A target can define a module or a test suite. | ||
// Targets can depend on other targets in this package, and on products in packages this package depends on. | ||
.target( | ||
name: "CEExtensionKit", | ||
dependencies: []), | ||
.testTarget( | ||
name: "CEExtensionKitTests", | ||
dependencies: ["CEExtensionKit"]), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# CEExtensionKit | ||
|
||
A description of this package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// ExtensionAPI.swift | ||
// | ||
// | ||
// Created by Pavel Kasila on 27.03.22. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A protocol to conform to for Extension API instance assigned to ``extensionId`` | ||
public protocol ExtensionAPI { | ||
|
||
var extensionId: String { get } | ||
|
||
/// API to work with targets | ||
var targets: TargetsAPI { get } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// ExtensionInterface.swift | ||
// | ||
// | ||
// Created by Pavel Kasila on 27.03.22. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A protocol for extensions to conform to | ||
public protocol ExtensionInterface { | ||
|
||
/// Initializes extension with API | ||
/// - Parameter withAPI: the API implementation itself | ||
init(withAPI api: ExtensionAPI) throws | ||
|
||
} | ||
|
||
open class ExtensionBuilder { | ||
|
||
public init() {} | ||
|
||
open func build() -> ExtensionInterface { | ||
fatalError("You should override ExtensionBuilder.build") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// Target.swift | ||
// | ||
// | ||
// Created by Pavel Kasila on 27.03.22. | ||
// | ||
|
||
import Foundation | ||
|
||
/// This structure stores information about the target to be available in CodeEdit for running | ||
public struct Target: Identifiable { | ||
|
||
/** | ||
* Initializes a target with parameters | ||
* - Parameter id: The unique identifier of the target set by the extension | ||
* - Parameter displayName: The name of the target to be displayed in the UI | ||
* - Parameter executable: The executable to launch inside the pseudo terminal | ||
* - Parameter args: an array of strings that is passed as the arguments to the underlying process | ||
* - Parameter environment: an array of environment variables to pass to the child process. | ||
* - 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. | ||
*/ | ||
public init(id: String, displayName: String, | ||
executable: String, args: [String] = [], | ||
environment: [String]? = nil, execName: String? = nil) { | ||
self.id = id | ||
self.displayName = displayName | ||
self.executable = executable | ||
self.args = args | ||
self.environment = environment | ||
self.execName = execName | ||
} | ||
|
||
/// ``id`` is a unique identifier of the target set by the extension | ||
public var id: String | ||
|
||
/// ``displayName`` is a name to be displayed in the UI to represent target | ||
public var displayName: String | ||
|
||
/// ``executable`` is the executable to launch inside the pseudo terminal | ||
public var executable: String | ||
|
||
/// ``args`` is an array of strings that is passed as the arguments to the underlying process | ||
public var args: [String] = [] | ||
|
||
/// ``environment`` is an array of environment variables to pass to the child process. | ||
public var environment: [String]? | ||
|
||
/// ``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. | ||
public var execName: String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// TargetsAPI.swift | ||
// | ||
// | ||
// Created by Pavel Kasila on 27.03.22. | ||
// | ||
|
||
import Foundation | ||
|
||
/// API for targets | ||
public protocol TargetsAPI { | ||
|
||
/// Adds new target to the list | ||
/// - Parameter target: the target to be added to the list | ||
func add(target: Target) | ||
|
||
/// Deletes a target from the list | ||
/// - Parameter target: the target to be removed from the list | ||
func delete(target: Target) | ||
|
||
/// Clears all targets from the list | ||
func clear() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import XCTest | ||
@testable import CEExtensionKit | ||
|
||
final class CEExtensionKitTests: XCTestCase { | ||
func testExample() throws { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct | ||
// results. | ||
} | ||
} |