Rename noms-view to noms-ui, remove serve option, cleanup (#1634)

This commit is contained in:
Ben Kalman
2016-05-25 11:15:49 -07:00
parent 998b7a9df0
commit 5e170e1ee2
8 changed files with 28 additions and 36 deletions
+3 -3
View File
@@ -14,16 +14,16 @@ npm run build
## Run
```
noms-view serve .
noms ui .
```
Then, navigate to the URL printed by noms-view, e.g. http://127.0.0.1:12345?store=xyz.
Then, navigate to the URL printed by `noms ui`, e.g. http://127.0.0.1:12345
## Develop
```
npm run start
noms-view serve .
noms ui .
```
## TODO
+4 -4
View File
@@ -17,13 +17,13 @@ go build
cd ../../js/splore
./build.py
# Launch Splore with noms-view
cd ../../../cmd/noms-view
# Launch Splore with noms-ui
cd ../../../cmd/noms-ui
go build
./noms-view serve ../../clients/js/splore db="ldb:/tmp/sploretest"
./noms-ui ../../clients/js/splore db="ldb:/tmp/sploretest"
```
Then, navigate to the URL printed by noms-view, e.g. http://127.0.0.1:12345?db=xyz.
Then, navigate to the URL printed by `noms-ui`, e.g. http://127.0.0.1:12345?db=xyz.
## Develop
+1
View File
@@ -0,0 +1 @@
noms-ui
+11
View File
@@ -0,0 +1,11 @@
# noms-ui
Serves noms browser UIs, from its own web and noms database server.
```
noms ui [-port PORT] directory [args...]
```
* `-port` serves on a custom port. By default `noms-ui` chooses a random port.
* `directory` specifies the directory of the browser UI. Browser URLs are relative to this directory, with `index.html` by default.
* `args` are a list of arguments to pass to the UI of the form `arg1=val`, `arg2=val2`, etc. `ldb:` values are automatically translated into paths to an HTTP noms database server.
@@ -21,12 +21,10 @@ import (
const (
dsPathPrefix = "/-ds"
serveCmd = "serve"
)
var (
hostFlag = flag.String("host", "localhost:0", "Host to listen on")
showHelp = flag.Bool("help", false, "Show help message")
portFlag = flag.Int("port", 0, "Port to listen on")
stdoutIsTty = flag.Int("stdout-is-tty", -1, "value of 1 forces tty ouput, 0 forces non-tty output (provided for use by other programs)")
)
@@ -39,25 +37,25 @@ type chunkStoreRecords map[string]chunkStoreRecord
func main() {
usage := func() {
fmt.Fprintln(os.Stderr, "Starts a server to display a web application with access to one or more noms datasets\n")
fmt.Printf("Usage: noms view %s <view-dir> arg1=val1 arg2=val2...\n", serveCmd)
fmt.Fprintln(os.Stderr, "Usage: noms ui [-host HOST] directory [args...]\n")
fmt.Fprintln(os.Stderr, " args are of the form arg1=val1, arg2=val2, etc. \"ldb:\" values are automatically translated into paths to an HTTP noms database server.\n")
flag.PrintDefaults()
}
flag.Parse()
flag.Usage = usage
if *showHelp || len(flag.Args()) < 2 || flag.Arg(0) != serveCmd {
if len(flag.Args()) == 0 {
usage()
os.Exit(1)
}
viewDir := flag.Arg(1)
qsValues, stores := constructQueryString(flag.Args()[2:])
uiDir := flag.Arg(0)
qsValues, stores := constructQueryString(flag.Args()[1:])
router := &httprouter.Router{
HandleMethodNotAllowed: true,
NotFound: http.FileServer(http.Dir(viewDir)),
NotFound: http.FileServer(http.Dir(uiDir)),
RedirectFixedPath: true,
}
@@ -70,7 +68,7 @@ func main() {
router.POST(prefix+constants.RootPath, routeToStore(stores, datas.HandleRootPost))
router.OPTIONS(prefix+constants.RootPath, routeToStore(stores, datas.HandleRootGet))
l, err := net.Listen("tcp", *hostFlag)
l, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", *portFlag))
d.Chk.NoError(err)
srv := &http.Server{
@@ -84,7 +82,7 @@ func main() {
qs = "?" + qsValues.Encode()
}
fmt.Printf("Starting view %s at http://%s%s\n", viewDir, l.Addr().String(), qs)
fmt.Printf("Starting UI %s at http://%s%s\n", uiDir, l.Addr().String(), qs)
log.Fatal(srv.Serve(l))
}
-1
View File
@@ -1 +0,0 @@
noms-view
-17
View File
@@ -1,17 +0,0 @@
# noms-view
Manages noms views. Usage:
```
noms view <flags> <command> ...
```
Supported commands:
* `serve`: serves a noms from from a local server
Examples:
## serve
```
./noms-view serve ../../clients/js/splore store=ldb:/tmp/picasa
```