github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/updater/windows/WpfPrompter/run.go (about) 1 // Copyright 2015 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 //go:build windows 5 // +build windows 6 7 package main 8 9 import ( 10 "encoding/json" 11 "os" 12 "path/filepath" 13 "time" 14 15 "github.com/kardianos/osext" 16 "github.com/keybase/client/go/updater/command" 17 "github.com/keybase/go-logging" 18 ) 19 20 // Copied here since it is not exported from go-updater/keybase 21 type updaterPromptInput struct { 22 Title string `json:"title"` 23 Message string `json:"message"` 24 Description string `json:"description"` 25 AutoUpdate bool `json:"autoUpdate"` 26 OutPath string `json:"outPath"` // Used for windows instead of stdout 27 } 28 29 func main() { 30 var testLog = &logging.Logger{Module: "test"} 31 32 exePathName, _ := osext.Executable() 33 pathName, _ := filepath.Split(exePathName) 34 outPathName := filepath.Join(pathName, "out.txt") 35 36 promptJSONInput, err := json.Marshal(updaterPromptInput{ 37 Title: "Keybase Update: Version Foobar", 38 Message: "The version you are currently running (0.0) is outdated.", 39 Description: "Recent changes:\n\n---------------\n\n- Introducing the main GUI screen - this is where you'll look people up, manage your folders, and perform other actions. A lot of the features are stubbed out, but you can start playing with it.\n\n- Sharing before signup - go ahead and put data in /keybase/private/you,friend@twitter/ . If you have any invite codes, this will pop up a window with a link to DM them. It also works for end-to-end encryption with Reddit, Coinbase, Github, and Hacker News users.\n\nWhat we are currently working on:\n\n---------------------------------\n\n- KBFS performance, including delayed writes\n\n", 40 AutoUpdate: true, 41 OutPath: outPathName, 42 }) 43 if err != nil { 44 testLog.Errorf("Error generating input: %s", err) 45 return 46 } 47 48 path := filepath.Join(pathName, "WpfApplication1\\bin\\Release\\prompter.exe") 49 50 testLog.Debugf("Executing: %s %s", path, string(string(promptJSONInput))) 51 52 _, err = command.Exec(path, []string{string(promptJSONInput)}, 100*time.Second, testLog) 53 if err != nil { 54 testLog.Errorf("Error: %v", err) 55 return 56 } 57 58 result, err := os.ReadFile(outPathName) 59 if err != nil { 60 testLog.Errorf("Error opening result file: %v", err) 61 return 62 } 63 64 testLog.Debugf("Result: %s", string(result)) 65 }