mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Fixed index.html start arg
This commit is contained in:
parent
70d32441c0
commit
e0b7090332
1 changed files with 22 additions and 19 deletions
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -21,24 +22,25 @@ import (
|
||||||
"github.com/docopt/docopt-go"
|
"github.com/docopt/docopt-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
var confui struct {
|
var usage = `Graphical interface for RiV mesh.
|
||||||
Console bool `docopt:"-c,--console"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
usage := `Graphical interface for RiV mesh.
|
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
mesh-ui
|
mesh-ui [<index>] [-c]
|
||||||
mesh-ui -c | --console
|
|
||||||
mesh-ui -h | --help
|
mesh-ui -h | --help
|
||||||
mesh-ui -v | --version
|
mesh-ui -v | --version
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
<index> Index file name [default: index.html].
|
||||||
-c --console Show debug console window.
|
-c --console Show debug console window.
|
||||||
-h --help Show this screen.
|
-h --help Show this screen.
|
||||||
-v --version Show version.`
|
-v --version Show version.`
|
||||||
|
|
||||||
|
var confui struct {
|
||||||
|
IndexHtml string `docopt:"<index>"`
|
||||||
|
Console bool `docopt:"-c,--console"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
opts, _ := docopt.ParseArgs(usage, os.Args[1:], "0.0.1")
|
opts, _ := docopt.ParseArgs(usage, os.Args[1:], "0.0.1")
|
||||||
opts.Bind(&confui)
|
opts.Bind(&confui)
|
||||||
if !confui.Console {
|
if !confui.Console {
|
||||||
|
@ -88,18 +90,21 @@ Options:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var path string
|
|
||||||
|
|
||||||
if len(os.Args) > 1 {
|
if confui.IndexHtml == "" {
|
||||||
path, err = filepath.Abs(filepath.Dir(os.Args[1]))
|
confui.IndexHtml = "index.html"
|
||||||
} else {
|
|
||||||
path, err = filepath.Abs(filepath.Dir(os.Args[0]))
|
|
||||||
}
|
}
|
||||||
|
confui.IndexHtml, err = filepath.Abs(confui.IndexHtml)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
panic(errors.New("Index file not found: " + err.Error()))
|
||||||
|
}
|
||||||
|
|
||||||
|
if stat, err := os.Stat(confui.IndexHtml); err != nil {
|
||||||
|
panic(errors.New("Index file not found or permissians denied: " + err.Error()))
|
||||||
|
} else if stat.IsDir() {
|
||||||
|
panic(errors.New(fmt.Sprintf("Index file %v not found", confui.IndexHtml)))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println(path)
|
|
||||||
w.Bind("onLoad", func() {
|
w.Bind("onLoad", func() {
|
||||||
log.Println("page loaded")
|
log.Println("page loaded")
|
||||||
go run(w)
|
go run(w)
|
||||||
|
@ -126,10 +131,8 @@ Options:
|
||||||
w.Bind("ping", func(peer_list string) {
|
w.Bind("ping", func(peer_list string) {
|
||||||
go ping(w, peer_list)
|
go ping(w, peer_list)
|
||||||
})
|
})
|
||||||
//dat, err := ioutil.ReadFile(path+"/index.html")
|
log.Printf("Opening: %v", confui.IndexHtml)
|
||||||
//w.Navigate("data:text/html,"+url.QueryEscape(string(dat)))
|
w.Navigate(confui.IndexHtml)
|
||||||
//w.Navigate("data:text/html,"+"<html>"+path+"</html>")
|
|
||||||
w.Navigate("file://" + path + "/index.html")
|
|
||||||
w.Run()
|
w.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue