Skip to content

Commit

Permalink
docs: add explanation of task runner
Browse files Browse the repository at this point in the history
mostly to trigger a release workflow, also to test some gpt prompts
  • Loading branch information
iloveitaly committed Apr 21, 2023
1 parent b7ab078 commit bb49c31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/hyper-focus/configuration_loader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ enum ConfigurationLoader {

return config
}
}
}
6 changes: 2 additions & 4 deletions Sources/hyper-focus/server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ class ApiServer {
scheduledUntil = Int(nowWithStartAndEnd.timeIntervalSince1970)
}


return [
"schedule": [
"name": self.scheduleManager.plannedSchedule?.name,
"until": scheduledUntil,
] as [String : Any?],
] as [String: Any?],
"override": [
"until": self.scheduleManager.endOverride?.timeIntervalSince1970,
"name": self.scheduleManager.overrideSchedule?.name,
Expand All @@ -69,7 +68,7 @@ class ApiServer {
router["/schedules"] = JSONResponse { _ -> Any in
let rawSchedules = self.scheduleManager.schedules()

// TODO there's got to be a better way to convert a codable object to JSON
// TODO: there's got to be a better way to convert a codable object to JSON
let schedules: [[String: Any]] = rawSchedules.map { schedule in
let jsonData = try! JSONEncoder().encode(schedule)
let json = try! JSONSerialization.jsonObject(with: jsonData) as! [String: Any]
Expand All @@ -79,7 +78,6 @@ class ApiServer {
return schedules
}


// http -vvv POST http://localhost:8080/override name='hyper focus' until=1667514400
router["/override"] = JSONResponse { environ -> Any in
log("/override")
Expand Down
5 changes: 5 additions & 0 deletions Sources/hyper-focus/taskrunner.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Cocoa
import Foundation

/**
This module runs shell commands. It ensures single-instance execution per task name and handles script execution timeouts.
Output is prefixed with task-specific identifier for easier identification in the logs.
*/

enum TaskRunner {
static var executionLocks: [String: Bool] = [:]

Expand Down

0 comments on commit bb49c31

Please sign in to comment.