-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
54 lines (46 loc) · 1.22 KB
/
main.go
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
54
package main
import (
"errors"
"fmt"
"log"
"os"
"github.com/urfave/cli/v2"
"github.com/yevbar/browserbased/browserbased"
)
func DeployFromFile(COBOLScriptPath string) *browserbased.BrowserbasedBrowser {
cobol, err := os.ReadFile(COBOLScriptPath)
if err != nil {
panic(err)
}
fmt.Println("Deploying a browserbased browser!")
browser, err := browserbased.CreateBrowserbasedBrowser(&browserbased.BrowserbasedBrowserConfig{
COBOLScript: string(cobol),
})
if err != nil {
panic(err)
}
fmt.Printf("Deployed to: %s\nTo access the browser go to %s\n", browser.DeployedURL, browser.BrowserURL)
return browser
}
func main() {
app := &cli.App{
Name: "deploy",
Usage: "Deploy a COBOL script to a headless browser",
Action: func(cCtx *cli.Context) error {
path := cCtx.Args().Get(0)
if len(path) == 0 {
fmt.Println("You must provide a path to a COBOL script to deploy it")
return nil
}
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
fmt.Printf("The path you provided [%s] is invalid, please provide a valid path to a COBOL script to deploy it\n", path)
return nil
}
DeployFromFile(path)
return nil
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}