Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pkasila committed Mar 27, 2022
0 parents commit 54f4976
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
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
28 changes: 28 additions & 0 deletions Package.swift
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"]),
]
)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CEExtensionKit

A description of this package.
18 changes: 18 additions & 0 deletions Sources/CEExtensionKit/ExtensionAPI.swift
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 }

}
26 changes: 26 additions & 0 deletions Sources/CEExtensionKit/ExtensionInterface.swift
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")
}
}
50 changes: 50 additions & 0 deletions Sources/CEExtensionKit/Targets/Target.swift
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?
}
24 changes: 24 additions & 0 deletions Sources/CEExtensionKit/TargetsAPI.swift
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()

}
10 changes: 10 additions & 0 deletions Tests/CEExtensionKitTests/CEExtensionKitTests.swift
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.
}
}

0 comments on commit 54f4976

Please sign in to comment.