Im building a cli app that can run in server mode for osx in golang. I come from the server world and have no idea how properly distribute a consumer cli tool for osx. The cli can run as a service which can be easily achieved with launchd.
Launchd config:
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>focus-daemon</string>
<key>RunAtLoad</key>
<true />
<key>Program</key>
<string>/usr/local/bin/focus</string>
</dict>
</plist>
Building and running is also quite simple:
go build main.go
sudo cp main /usr/local/bin/focus
rm main
sudo chown root /usr/local/bin/focus
sudo chmod 4555 /usr/local/bin/focus
cp focus.plist ~/Library/LaunchAgents/com.21stio.focus.plist
launchctl load ~/Library/LaunchAgents/com.21stio.focus.plist
When being build the process requires sudo to set a sbit on the binary.
I don't want the user having to run a .sh script. Maybe I could use brew and/or a DMG for that. But I have no idea how I can put the Launchd config
at the right spot then.