FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CopilotForXcode/Helper/ReloadLaunchAgent.swift at main · GoodOpenRepo/CopilotForXcode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
GoodOpenRepo
/
CopilotForXcode
Public
forked from
intitni/CopilotForXcode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
CopilotForXcode
/
Helper
/
ReloadLaunchAgent.swift
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (44 loc) · 1.36 KB
Breadcrumbs
CopilotForXcode
/
Helper
/
ReloadLaunchAgent.swift
Copy path
File metadata and controls
53 lines (44 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import
ArgumentParser
import
Foundation
struct
ReloadLaunchAgent
:
ParsableCommand
{
static
var
configuration
=
CommandConfiguration
(
abstract
:
"
Reload the launch agent
"
)
@
Option
(
name
:
.
long
,
help
:
"
The service identifier of the service.
"
)
var
serviceIdentifier
:
String
var
launchAgentDirURL
:
URL
{
FileManager
.
default
.
homeDirectoryForCurrentUser
.
appendingPathComponent
(
"
Library/LaunchAgents
"
)
}
var
launchAgentPath
:
String
{
launchAgentDirURL
.
appendingPathComponent
(
"
\(
serviceIdentifier
)
.plist
"
)
.
path
}
func
run
(
)
throws
{
try
?
launchctl
(
"
unload
"
,
launchAgentPath
)
try
launchctl
(
"
load
"
,
launchAgentPath
)
}
}
private
func
launchctl
(
_ args
:
String
...
)
throws
{
return
try
process
(
"
/bin/launchctl
"
,
args
)
}
private
func
process
(
_ launchPath
:
String
,
_ args
:
[
String
]
)
throws
{
let
task
=
Process
(
)
task
.
launchPath
=
launchPath
task
.
arguments
=
args
task
.
environment
=
[
"
PATH
"
:
"
/usr/bin
"
,
]
let
outpipe
=
Pipe
(
)
task
.
standardOutput
=
outpipe
try
task
.
run
(
)
task
.
waitUntilExit
(
)
struct
E
:
Error
,
LocalizedError
{
var
errorDescription
:
String
?
}
if
task
.
terminationStatus
==
0
{
return
}
throw
E
(
errorDescription
:
"
Failed to restart. Please make sure the launch agent is already loaded.
"
)
}
Back
|
FazBrowse Home
|
New Git URL