ref: a2ba82de7407e3fc7e0b1c6aaf30ee9a35a4fff2
parent: a3d9d2db87066930398d89a3781bb2f3b06a0b83
author: Philip Silva <philip.silva@protonmail.com>
date: Sat Jul 10 07:01:17 EDT 2021
More condensed cli options
--- a/.gitignore
+++ b/.gitignore
@@ -6,8 +6,9 @@
*.prof
*.swp
*.tgz
+*.gz
+*.bz2
~*
.DS_Store
-/cmd/browse/browse
-/cmd/jsfs/jsfs
-main.js
+/cmd/opossum/opossum
+/cmd/gojafs/gojafs
--- a/README.md
+++ b/README.md
@@ -25,30 +25,32 @@
hget https://curl.haxx.se/ca/cacert.pem > /sys/lib/tls/ca.pem
```
-### Binary
+Create mountpoint (only needed on 9legacy):
-A recent binary for amd64 and 386 can be downloaded from http://psilva.sdf.org/opossum.html
-
-### Compile from Source
-
```
-go install ./cmd/opossum
+mkdir /mnt/opossum
```
-There are various command line options, visible with `-h`, most importantly to see errors:
+### Binary
-```
-opossum '-quiet=false'
-```
+A binary for amd64 and 386 can be downloaded from http://psilva.sdf.org/opossum.html
-(`-quiet=false` produces a lot of output, consider turning on scroll since processing waits for that...)
+### Compile from Source
-or all messages:
+ go install ./cmd/opossum
-```
-opossum '-quiet=false' '-debug=true'
-```
+Command line options:
+ -h help
+ -v verbose
+ -vv print debug messages
+ -jsinsecure activate js
+ -cpuprofile filename create cpuprofile
+
+(-v and -vv produce a lot of output,
+consider turning on scroll since processing
+waits for that...)
+
`$font` is used to select the font.
## macOS
@@ -87,18 +89,11 @@
```
-Then try on Plan 9 with e.g.:
+Then it can be tested with:
```
-opossum '-experimentalJsInsecure=true' -startPage https://jqueryui.com/resources/demos/tabs/default.html
+opossum -jsinsecure https://jqueryui.com/resources/demos/tabs/default.html
```
-
-or macOS etc.:
-
-```
-opossum -experimentalJsInsecure=true -startPage https://jqueryui.com/resources/demos/tabs/default.html
-```
-
# TODO
--- a/browser/browser.go
+++ b/browser/browser.go
@@ -55,9 +55,8 @@
0b00001100, 0b01111000,
}
-var DebugDumpCSS *bool
-var ExperimentalJsInsecure *bool
-var EnableNoScriptTag *bool
+var ExperimentalJsInsecure bool
+var EnableNoScriptTag bool
var browser *Browser
var Style = style.Map{}
@@ -664,7 +663,7 @@
return e.Consumed
}
- if !*ExperimentalJsInsecure {
+ if !ExperimentalJsInsecure {
return
}
@@ -1125,7 +1124,7 @@
el = InnerNodesToBox(r+1, b, n)
el.makeLink(href)
case "noscript":
- if *ExperimentalJsInsecure || !*EnableNoScriptTag {
+ if ExperimentalJsInsecure || !EnableNoScriptTag {
return
}
fallthrough
@@ -1366,7 +1365,7 @@
}
display = dui.Display
- if *ExperimentalJsInsecure {
+ if ExperimentalJsInsecure {
fs.Client = &http.Client{}
fs.Fetcher = browser
}
--- a/browser/browser_test.go
+++ b/browser/browser_test.go
@@ -18,10 +18,6 @@
)
func init() {
- quiet := false
- logger.Quiet = &quiet
- js := false
- ExperimentalJsInsecure = &js
logger.Init()
SetLogger(&logger.Logger{})
style.Init(nil, &logger.Logger{})
@@ -141,12 +137,11 @@
}
func TestNilPanic(t *testing.T) {
- //f, err := os.Open()
}
func TestNodeToBoxNoscript(t *testing.T) {
enable := true
- EnableNoScriptTag = &enable
+ EnableNoScriptTag = enable
htm := `
<body>
<noscript>
--- a/browser/experimental_test.go
+++ b/browser/experimental_test.go
@@ -14,10 +14,6 @@
)
func init() {
- quiet := false
- logger.Quiet = &quiet
- f := false
- js.DebugDumpJS = &f
js.SetLogger(&logger.Logger{})
logger.Init()
SetLogger(&logger.Logger{})
@@ -27,8 +23,6 @@
}
func TestAtom(t *testing.T) {
- //var ui duit.UI
- //ui = &Atom{}
}
func TestProcessJS2SkipFailure(t *testing.T) {
--- a/browser/website.go
+++ b/browser/website.go
@@ -4,7 +4,6 @@
"github.com/mjl-/duit"
"golang.org/x/net/html"
"golang.org/x/text/encoding"
- "io/ioutil"
"net/url"
"github.com/psilva261/opossum"
"github.com/psilva261/opossum/browser/duitx"
@@ -39,7 +38,7 @@
var err error
doc, err = html.ParseWithOptions(
strings.NewReader(htm),
- html.ParseOptionEnableScripting(*ExperimentalJsInsecure),
+ html.ParseOptionEnableScripting(ExperimentalJsInsecure),
)
if err != nil {
panic(err.Error())
@@ -61,9 +60,6 @@
style.MergeNodeMaps(nodeMap, nm)
} else {
log.Errorf("Fetch CSS Rules failed: %v", err)
- if *DebugDumpCSS {
- ioutil.WriteFile("info.css", []byte(css), 0644)
- }
}
}
@@ -81,7 +77,7 @@
// 3rd pass is only needed initially to load the scripts and set the goja VM
// state. During subsequent calls from click handlers that state is kept.
var scripts []string
- if *ExperimentalJsInsecure && layouting != ClickRelayout {
+ if ExperimentalJsInsecure && layouting != ClickRelayout {
log.Printf("3rd pass")
nt := nodes.NewNodeTree(doc, style.Map{}, nodeMap, nil)
jsSrcs := js.Srcs(nt)
--- a/cmd/gojafs/domino/domino.go
+++ b/cmd/gojafs/domino/domino.go
@@ -23,7 +23,6 @@
"time"
)
-var DebugDumpJS *bool
var log *logger.Logger
var timeout = 60*time.Second
@@ -157,10 +156,6 @@
SCRIPT := domIntf + script
if !initial {
SCRIPT = script
- }
-
- if *DebugDumpJS {
- ioutil.WriteFile("main.js", []byte(SCRIPT), 0644)
}
ready := make(chan goja.Value)
--- a/cmd/gojafs/domino/domino_test.go
+++ b/cmd/gojafs/domino/domino_test.go
@@ -20,10 +20,6 @@
`
func init() {
- f := false
- t := true
- DebugDumpJS = &t
- logger.Quiet = &f
logger.Init()
log = &logger.Logger{Debug: true}
}
--- a/cmd/gojafs/main.go
+++ b/cmd/gojafs/main.go
@@ -31,10 +31,7 @@
)
func init() {
- f := false
- t := true
- domino.DebugDumpJS = &f
- logger.Quiet = &t
+ logger.Quiet = true
logger.Init()
log = &logger.Logger{Debug: true}
domino.SetLogger(log)
@@ -46,7 +43,6 @@
}
func Main(r io.Reader, w io.Writer) (err error) {
- log.Infof("Main...\n")
u, err := user.Current()
if err != nil {
return fmt.Errorf("get user: %v", err)
--- a/cmd/opossum/main.go
+++ b/cmd/opossum/main.go
@@ -2,7 +2,6 @@
import (
"9fans.net/go/draw"
- "flag"
"fmt"
"image"
"os"
@@ -21,21 +20,15 @@
"github.com/mjl-/duit"
)
-const debugPrintHtml = false
-
var dui *duit.DUI
var log *logger.Logger
-var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
-var startPage = flag.String("startPage", "http://9p.io", "")
-var dbg = flag.Bool("debug", false, "show debug logs")
+var cpuprofile string
+var startPage string = "http://9p.io"
+var dbg bool
func init() {
- browser.DebugDumpCSS = flag.Bool("debugDumpCSS", false, "write css to info.css")
- js.DebugDumpJS = flag.Bool("debugDumpJS", false, "write js to main.js")
- browser.ExperimentalJsInsecure = flag.Bool("experimentalJsInsecure", false, "DO NOT ACTIVATE UNLESS INSTRUCTED OTHERWISE")
- browser.EnableNoScriptTag = flag.Bool("enableNoScriptTag", false, "enable noscript tag")
- logger.Quiet = flag.Bool("quiet", defaultQuietActive, "don't print info messages and non-fatal errors")
+ browser.EnableNoScriptTag = false
}
func mainView(b *browser.Browser) []*duit.Kid {
@@ -132,6 +125,7 @@
if err != nil {
return fmt.Errorf("new dui: %w", err)
}
+ dui.Debug = dbg
style.Init(dui, log)
browser.SetLogger(log)
@@ -141,7 +135,7 @@
opossum.SetLogger(log)
nodes.SetLogger(log)
- b := browser.NewBrowser(dui, *startPage)
+ b := browser.NewBrowser(dui, startPage)
b.Download = func(done chan int) chan string {
go func() {
<-done
@@ -167,12 +161,42 @@
}
}
+func usage() {
+ fmt.Printf("usage: opossum [-v|-vv] [-h] [-jsinsecure] [-cpuprofile fn] [startPage]\n")
+ os.Exit(1)
+}
+
func main() {
- flag.Parse()
+ logger.Quiet = true
+ args := os.Args[1:]
+ for len(args) > 0 {
+ switch args[0] {
+ case "-vv":
+ logger.Quiet = false
+ dbg = true
+ args = args[1:]
+ case "-v":
+ logger.Quiet = false
+ args = args[1:]
+ case "-h":
+ usage()
+ args = args[1:]
+ case "-jsinsecure":
+ browser.ExperimentalJsInsecure = true
+ args = args[1:]
+ case "-cpuprofile":
+ cpuprofile, args = args[0], args[2:]
+ default:
+ if len(args) > 1 {
+ usage()
+ }
+ startPage, args = args[0], args[1:]
+ }
+ }
logger.Init()
- if *cpuprofile != "" {
- f, err := os.Create(*cpuprofile)
+ if cpuprofile != "" {
+ f, err := os.Create(cpuprofile)
if err != nil {
log.Fatal(err)
}
@@ -185,7 +209,7 @@
}
log = logger.Log
- log.Debug = *dbg
+ log.Debug = dbg
go9p.Verbose = log.Debug
done := make(chan os.Signal, 1)
--- a/cmd/opossum/main_plan9.go
+++ /dev/null
@@ -1,3 +1,0 @@
-package main
-
-const defaultQuietActive = true
--- a/cmd/opossum/main_unix.go
+++ /dev/null
@@ -1,5 +1,0 @@
-// +build !plan9
-
-package main
-
-const defaultQuietActive = false
--- a/img/img_test.go
+++ b/img/img_test.go
@@ -6,8 +6,6 @@
)
func init() {
- f := false
- logger.Quiet = &f
logger.Init()
log = &logger.Logger{Debug: true}
SetLogger(&logger.Logger{})
--- a/js/js.go
+++ b/js/js.go
@@ -19,7 +19,6 @@
"time"
)
-var DebugDumpJS *bool
var log *logger.Logger
var timeout = 60*time.Second
--- a/js/js_test.go
+++ b/js/js_test.go
@@ -20,10 +20,6 @@
`
func init() {
- f := false
- t := true
- DebugDumpJS = &t
- logger.Quiet = &f
logger.Init()
log = &logger.Logger{Debug: true}
fs.SetLogger(log)
--- a/logger/logger.go
+++ b/logger/logger.go
@@ -10,7 +10,7 @@
// Sink for Go's log pkg
var Sink io.Writer
-var Quiet *bool
+var Quiet bool
var Log *Logger
var gl *goLog.Logger
@@ -17,7 +17,7 @@
func Init() {
gl = goLog.New(os.Stderr, "", goLog.LstdFlags)
Log = &Logger{}
- if *Quiet {
+ if Quiet {
Sink = &NullWriter{}
goLog.SetOutput(Sink)
}
@@ -80,7 +80,7 @@
if severity == debug && !l.Debug {
return
}
- if (severity != fatal && severity != flush) && *Quiet {
+ if (severity != fatal && severity != flush) && Quiet {
return
}
--- a/style/stylesheets_test.go
+++ b/style/stylesheets_test.go
@@ -10,8 +10,6 @@
)
func init() {
- f := false
- logger.Quiet = &f
logger.Init()
log = &logger.Logger{Debug: true}
}