67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/wailsapp/wails/v2"
|
|
"github.com/wailsapp/wails/v2/pkg/options"
|
|
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
|
)
|
|
|
|
//go:embed all:frontend/dist
|
|
var assets embed.FS
|
|
|
|
// profileArg extracts a profile name from the command line. Accepts
|
|
// "--profile NAME", "--profile=NAME", "-profile NAME", "-p NAME" so a desktop
|
|
// shortcut can launch OpsLog straight into a given profile (e.g. F4BPO / TM2Q).
|
|
func profileArg(args []string) string {
|
|
for i := 0; i < len(args); i++ {
|
|
a := args[i]
|
|
switch {
|
|
case a == "--profile" || a == "-profile" || a == "-p":
|
|
if i+1 < len(args) {
|
|
return strings.TrimSpace(args[i+1])
|
|
}
|
|
case strings.HasPrefix(a, "--profile="):
|
|
return strings.TrimSpace(strings.TrimPrefix(a, "--profile="))
|
|
case strings.HasPrefix(a, "-profile="):
|
|
return strings.TrimSpace(strings.TrimPrefix(a, "-profile="))
|
|
case strings.HasPrefix(a, "-p="):
|
|
return strings.TrimSpace(strings.TrimPrefix(a, "-p="))
|
|
}
|
|
}
|
|
return ""
|
|
}
|
|
|
|
func main() {
|
|
// Create an instance of the app structure
|
|
app := NewApp()
|
|
app.startupProfile = profileArg(os.Args[1:])
|
|
|
|
// Create application with options
|
|
err := wails.Run(&options.App{
|
|
Title: "OpsLog",
|
|
Width: 1400,
|
|
Height: 900,
|
|
MinWidth: 1100,
|
|
MinHeight: 700,
|
|
WindowStartState: options.Maximised,
|
|
AssetServer: &assetserver.Options{
|
|
Assets: assets,
|
|
},
|
|
BackgroundColour: &options.RGBA{R: 250, G: 250, B: 249, A: 1},
|
|
OnStartup: app.startup,
|
|
OnBeforeClose: app.beforeClose,
|
|
OnShutdown: app.shutdown,
|
|
Bind: []interface{}{
|
|
app,
|
|
},
|
|
})
|
|
|
|
if err != nil {
|
|
println("Error:", err.Error())
|
|
}
|
|
}
|