vendor: update eclier

This commit is contained in:
Cadey Ratio 2018-01-21 22:08:38 -08:00
parent 1dfde5c636
commit 814f75be29
9 changed files with 95 additions and 10 deletions

4
Gopkg.lock generated
View File

@ -11,7 +11,7 @@
branch = "master"
name = "github.com/Xe/eclier"
packages = ["."]
revision = "0348e605dd81108be0380a581f237d6c77e088fa"
revision = "d6e616ba8bbeba4bbcad640f00ca897524936927"
[[projects]]
branch = "master"
@ -977,6 +977,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "5a2781494dfd7bbba13e0088752aa52bd2b2e0a9e384f44ee165e5e4aacb7dfd"
inputs-digest = "16ca48f15cb2a6b7b52c758e9cc9aacc15a290406fc78798595d4cb5a513720b"
solver-name = "gps-cdcl"
solver-version = 1

16
mage.go
View File

@ -6,6 +6,7 @@ import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"runtime"
@ -50,7 +51,7 @@ func Dep() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
shouldWork(ctx, nil, wd, "dep", "ensure")
shouldWork(ctx, nil, wd, "dep", "ensure", "-update")
shouldWork(ctx, nil, wd, "dep", "prune")
}
@ -178,6 +179,19 @@ func Generate(ctx context.Context) {
dir := filepath.Join(wd, "proto")
shouldWork(ctx, nil, dir, "sh", "./regen.sh")
e, err := asarPack("./proto/eclier")
if err != nil {
log.Fatal(err)
}
fout, err := os.Create("./bin/scripts.asar")
if err != nil {
log.Fatal(err)
}
defer fout.Close()
e.EncodeTo(fout)
}
// Vars shows the various variables that this magefile uses.

View File

@ -4,14 +4,18 @@ package main
import (
"context"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"github.com/jtolds/qod"
"github.com/kr/fs"
"github.com/pkg/errors"
"layeh.com/asar"
)
func output(cmd string, args ...string) (string, error) {
@ -72,3 +76,32 @@ func goBuildPlugin(ctx context.Context, dir, pkgname, fname string) {
shouldWork(ctx, nil, dir, "go", "build", "-v", "-buildmode=plugin", "-o="+fname, pkgBase+pkgname)
qod.Printlnf("built %s for %s", fname, runtime.GOOS)
}
func asarPack(dir string) (*asar.Entry, error) {
b := &asar.Builder{}
w := fs.Walk(dir)
for w.Step() {
if err := w.Err(); err != nil {
fmt.Printf("walk error: %v\n", err)
continue
}
p := w.Path()
st := w.Stat()
if st.IsDir() {
w.SkipDir()
}
fin, err := os.Open(p)
if err != nil {
return nil, err
}
defer fin.Close()
b.Add(filepath.Base(p), fin, st.Size(), asar.FlagNone)
}
return b.Root(), nil
}

View File

@ -13,9 +13,9 @@ local svc = require "svc"
local fs = flag.new()
-- flags for Route
fs:string("host", "", "value for message arg host")
fs:string("id", "", "value for message arg id")
fs:string("creator", "", "value for message arg creator")
fs:string("host", "", "value for message arg host")
script.usage = fs:usage()

View File

@ -13,10 +13,10 @@ local svc = require "svc"
local fs = flag.new()
-- flags for Token
fs:string("id", "", "value for message arg id")
fs:string("body", "", "value for message arg body")
fs:strings("scopes", "value for message arg scopes")
fs:bool("active", false, "value for message arg active")
fs:string("id", "", "value for message arg id")
script.usage = fs:usage()

View File

@ -13,10 +13,10 @@ local svc = require "svc"
local fs = flag.new()
-- flags for Token
fs:string("body", "", "value for message arg body")
fs:strings("scopes", "value for message arg scopes")
fs:bool("active", false, "value for message arg active")
fs:string("id", "", "value for message arg id")
fs:string("body", "", "value for message arg body")
script.usage = fs:usage()

View File

@ -13,10 +13,10 @@ local svc = require "svc"
local fs = flag.new()
-- flags for Token
fs:bool("active", false, "value for message arg active")
fs:string("id", "", "value for message arg id")
fs:string("body", "", "value for message arg body")
fs:strings("scopes", "value for message arg scopes")
fs:bool("active", false, "value for message arg active")
script.usage = fs:usage()

View File

@ -3,6 +3,9 @@ package eclier
import (
"context"
"flag"
"os"
"github.com/olekukonko/tablewriter"
)
// Constants for built-in commands.
@ -53,7 +56,8 @@ func (p *pluginCommand) Version() string { return BuiltinVersion }
func (p *pluginCommand) Run(ctx context.Context, arg []string) error {
p.fs.Parse(arg)
table.SetHeader([]String{"Verb", "Path"})
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Verb", "Path"})
for _, c := range p.r.cmds {
if c.ScriptPath() == BuiltinScriptPath && *p.dontShowBuiltin {

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"strings"
@ -139,6 +140,37 @@ func WithGluaCreationHook(hook func(*lua.LState)) RouterOption {
}
}
// WithFilesystem loads a http.FileSystem full of lua scripts into this eclier
// router.
func WithFilesystem(shortName string, fs http.FileSystem) RouterOption {
return func(r *Router) {
fin, err := fs.Open("/")
if err != nil {
log.Fatal(err)
}
defer fin.Close()
childs, err := fin.ReadDir(-1)
if err != nil {
log.Fatal(err)
}
for _, chl := range childs {
if strings.HasSuffix(chl.Name(), ".lua") {
fname := filepath.Join(shortName, chl.Name())
sFin, err := fs.Open(chl.Name())
if err != nil {
log.Fatal(err)
}
defer sFin.Close()
c := newGluaCommand(r.gluaCreationHook, fname, sFin)
r.cmds[c.Verb()] = c
}
}
}
}
// WithAsarFile loads an asar file full of lua scripts into this eclier router.
func WithAsarFile(shortName, fname string) RouterOption {
return func(r *Router) {
@ -153,7 +185,7 @@ func WithAsarFile(shortName, fname string) RouterOption {
log.Fatal(err)
}
err := e.Walk(func(path string, info os.FileInfo, err error) error {
err = e.Walk(func(path string, info os.FileInfo, err error) error {
if strings.HasSuffix(info.Name(), ".lua") {
fname := filepath.Join(shortName, "::", path)
fin := e.Find(path)
@ -161,9 +193,11 @@ func WithAsarFile(shortName, fname string) RouterOption {
return nil
}
c = newGluaCommand(r.gluaCreationHook, fname, fin)
c := newGluaCommand(r.gluaCreationHook, fname, fin.Open())
r.cmds[c.Verb()] = c
}
return nil
})
if err != nil {
log.Fatal(err)