feat: Added --profile argument to start OpsLog on specific profile
This commit is contained in:
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
@@ -11,9 +13,32 @@ import (
|
||||
//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{
|
||||
|
||||
Reference in New Issue
Block a user