mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 17:48:30 +02:00
Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
b13246978a | |||
a39d36cd34 | |||
87cba04ff2 | |||
bc623da74b | |||
a6c25d4b9c | |||
e24ac2b385 | |||
e0c35a74d4 | |||
3e4c1818a9 | |||
7b4a268ebd | |||
f7183aa17a | |||
1ce6c29e6a | |||
219db679e1 | |||
53177cb09d | |||
ef7a41f9a9 | |||
008316d030 | |||
a59c019642 | |||
57225442be | |||
2c7ce48859 | |||
a3fe4f40bb | |||
506fb8be15 | |||
408e944eea | |||
8a313b92ca | |||
6912771c39 | |||
d4c6200702 | |||
9251849d23 | |||
313b5ebd27 | |||
ca91b25b02 | |||
bbf6af50b1 | |||
9f05442bce | |||
3fc4c2f89e | |||
9e88ff2642 | |||
e3764b81e7 | |||
3786ac96a5 | |||
4cb7a3b42c | |||
ff6a866abe | |||
2e7ccb2a68 | |||
126231db1f | |||
91f0d02de2 | |||
815e714fb4 | |||
bd3986a051 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
dist
|
dist
|
||||||
|
tags
|
||||||
|
11
.travis.yml
11
.travis.yml
@ -2,3 +2,14 @@ language: go
|
|||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.13.x
|
- 1.13.x
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
|
||||||
|
install: true
|
||||||
|
|
||||||
|
script: make ci
|
||||||
|
161
Makefile
Normal file
161
Makefile
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
# paths
|
||||||
|
makefile := $(realpath $(lastword $(MAKEFILE_LIST)))
|
||||||
|
cmd_dir := ./cmd/cheat
|
||||||
|
dist_dir := ./dist
|
||||||
|
|
||||||
|
# executables
|
||||||
|
CAT := cat
|
||||||
|
COLUMN := column
|
||||||
|
CTAGS := ctags
|
||||||
|
GO := go
|
||||||
|
GREP := grep
|
||||||
|
GZIP := gzip --best
|
||||||
|
LINT := revive
|
||||||
|
MKDIR := mkdir -p
|
||||||
|
RM := rm
|
||||||
|
SCC := scc
|
||||||
|
SED := sed
|
||||||
|
SORT := sort
|
||||||
|
ZIP := zip -m
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
BUILD_FLAGS := -ldflags="-s -w" -mod vendor -trimpath
|
||||||
|
GOBIN :=
|
||||||
|
TMPDIR := /tmp
|
||||||
|
|
||||||
|
# release binaries
|
||||||
|
releases := \
|
||||||
|
$(dist_dir)/cheat-darwin-amd64 \
|
||||||
|
$(dist_dir)/cheat-linux-amd64 \
|
||||||
|
$(dist_dir)/cheat-linux-arm5 \
|
||||||
|
$(dist_dir)/cheat-linux-arm6 \
|
||||||
|
$(dist_dir)/cheat-linux-arm7 \
|
||||||
|
$(dist_dir)/cheat-windows-amd64.exe
|
||||||
|
|
||||||
|
## build: builds an executable for your architecture
|
||||||
|
.PHONY: build
|
||||||
|
build: $(dist_dir) clean generate
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $(dist_dir)/cheat $(cmd_dir)
|
||||||
|
|
||||||
|
## build-release: builds release executables
|
||||||
|
.PHONY: build-release
|
||||||
|
build-release: $(releases)
|
||||||
|
|
||||||
|
## ci: builds a "release" executable for the current architecture (used in ci)
|
||||||
|
.PHONY: ci
|
||||||
|
ci: | setup prepare build
|
||||||
|
|
||||||
|
# cheat-darwin-amd64
|
||||||
|
$(dist_dir)/cheat-darwin-amd64: prepare
|
||||||
|
GOARCH=amd64 GOOS=darwin \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-amd64
|
||||||
|
$(dist_dir)/cheat-linux-amd64: prepare
|
||||||
|
GOARCH=amd64 GOOS=linux \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm5
|
||||||
|
$(dist_dir)/cheat-linux-arm5: prepare
|
||||||
|
GOARCH=arm GOOS=linux GOARM=5 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm6
|
||||||
|
$(dist_dir)/cheat-linux-arm6: prepare
|
||||||
|
GOARCH=arm GOOS=linux GOARM=6 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-linux-arm7
|
||||||
|
$(dist_dir)/cheat-linux-arm7: prepare
|
||||||
|
GOARCH=arm GOOS=linux GOARM=7 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@ && chmod -x $@.gz
|
||||||
|
|
||||||
|
# cheat-windows-amd64
|
||||||
|
$(dist_dir)/cheat-windows-amd64.exe: prepare
|
||||||
|
GOARCH=amd64 GOOS=windows \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(ZIP) $@.zip $@
|
||||||
|
|
||||||
|
# ./dist
|
||||||
|
$(dist_dir):
|
||||||
|
$(MKDIR) $(dist_dir)
|
||||||
|
|
||||||
|
.PHONY: generate
|
||||||
|
generate:
|
||||||
|
$(GO) generate $(cmd_dir)
|
||||||
|
|
||||||
|
## install: builds and installs cheat on your PATH
|
||||||
|
.PHONY: install
|
||||||
|
install:
|
||||||
|
$(GO) install $(BUILD_FLAGS) $(GOBIN) $(cmd_dir)
|
||||||
|
|
||||||
|
## clean: removes compiled executables
|
||||||
|
.PHONY: clean
|
||||||
|
clean: $(dist_dir)
|
||||||
|
$(RM) -f $(dist_dir)/*
|
||||||
|
|
||||||
|
## distclean: removes the tags file
|
||||||
|
.PHONY: distclean
|
||||||
|
distclean:
|
||||||
|
$(RM) -f tags
|
||||||
|
|
||||||
|
## setup: installs revive (linter) and scc (sloc tool)
|
||||||
|
.PHONY: setup
|
||||||
|
setup:
|
||||||
|
GO111MODULE=off $(GO) get -u github.com/boyter/scc github.com/mgechev/revive
|
||||||
|
|
||||||
|
## sloc: counts "semantic lines of code"
|
||||||
|
.PHONY: sloc
|
||||||
|
sloc:
|
||||||
|
$(SCC) --exclude-dir=vendor
|
||||||
|
|
||||||
|
## tags: builds a tags file
|
||||||
|
.PHONY: tags
|
||||||
|
tags:
|
||||||
|
$(CTAGS) -R --exclude=vendor --languages=go
|
||||||
|
|
||||||
|
## vendor: downloads, tidies, and verifies dependencies
|
||||||
|
.PHONY: vendor
|
||||||
|
vendor:
|
||||||
|
$(GO) mod vendor && $(GO) mod tidy && $(GO) mod verify
|
||||||
|
|
||||||
|
## fmt: runs go fmt
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
$(GO) fmt ./...
|
||||||
|
|
||||||
|
## lint: lints go source files
|
||||||
|
.PHONY: lint
|
||||||
|
lint: vendor
|
||||||
|
$(LINT) -exclude vendor/... ./...
|
||||||
|
|
||||||
|
## vet: vets go source files
|
||||||
|
.PHONY: vet
|
||||||
|
vet:
|
||||||
|
$(GO) vet ./...
|
||||||
|
|
||||||
|
## test: runs unit-tests
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
$(GO) test ./...
|
||||||
|
|
||||||
|
## coverage: generates a test coverage report
|
||||||
|
.PHONY: coverage
|
||||||
|
coverage:
|
||||||
|
$(GO) test ./... -coverprofile=$(TMPDIR)/cheat-coverage.out && \
|
||||||
|
$(GO) tool cover -html=$(TMPDIR)/cheat-coverage.out
|
||||||
|
|
||||||
|
## check: formats, lints, vets, vendors, and run unit-tests
|
||||||
|
.PHONY: check
|
||||||
|
check: | vendor fmt lint vet test
|
||||||
|
|
||||||
|
.PHONY: prepare
|
||||||
|
prepare: | $(dist_dir) clean generate vendor fmt lint vet test
|
||||||
|
|
||||||
|
## help: displays this help text
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@$(CAT) $(makefile) | \
|
||||||
|
$(SORT) | \
|
||||||
|
$(GREP) "^##" | \
|
||||||
|
$(SED) 's/## //g' | \
|
||||||
|
$(COLUMN) -t -s ':'
|
17
README.md
17
README.md
@ -125,6 +125,11 @@ If a user attempts to edit a cheatsheet on a read-only cheatpath, `cheat` will
|
|||||||
transparently copy that sheet to a writeable directory before opening it for
|
transparently copy that sheet to a writeable directory before opening it for
|
||||||
editing.
|
editing.
|
||||||
|
|
||||||
|
### Directory-scoped Cheatpaths ###
|
||||||
|
At times, it can be useful to closely associate cheatsheets with a directory on
|
||||||
|
your filesystem. `cheat` facilitates this by searching for a `.cheat` folder in
|
||||||
|
the current working directory. If found, the `.cheat` directory will
|
||||||
|
(temporarily) be added to the cheatpaths.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
@ -188,9 +193,17 @@ cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
|||||||
|
|
||||||
Advanced Usage
|
Advanced Usage
|
||||||
--------------
|
--------------
|
||||||
`cheat` may be integrated with [fzf][]. See [fzf.bash][bash] for instructions.
|
Shell autocompletion is currently available for the `bash` and `fish` shells.
|
||||||
(Support for other shells will be added in future releases.)
|
Copy the relevant [completion script][completion-scripts] into the appropriate
|
||||||
|
directory on your filesystem to enable autocompletion. (This directory will
|
||||||
|
vary depending on operating system and shell specifics.)
|
||||||
|
|
||||||
|
Additionally, `cheat` supports enhanced autocompletion via integration with
|
||||||
|
[fzf][]. (This feature is currently available on bash only.) To enable `fzf`
|
||||||
|
integration:
|
||||||
|
|
||||||
|
1. Ensure that `fzf` is available on your `$PATH`
|
||||||
|
2. Set an envvar: `export CHEAT_USE_FZF=true`
|
||||||
|
|
||||||
[Releases]: https://github.com/cheat/cheat/releases
|
[Releases]: https://github.com/cheat/cheat/releases
|
||||||
[bash]: https://github.com/cheat/cheat/blob/master/scripts/fzf.bash
|
[bash]: https://github.com/cheat/cheat/blob/master/scripts/fzf.bash
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# locate the cheat project root
|
|
||||||
BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
APPDIR=$(readlink -f "$BINDIR/..")
|
|
||||||
|
|
||||||
# update the vendored dependencies
|
|
||||||
go mod vendor && go mod tidy
|
|
||||||
|
|
||||||
# compile the executable
|
|
||||||
cd "$APPDIR/cmd/cheat"
|
|
||||||
go clean && go generate && go build -mod vendor
|
|
||||||
mv "$APPDIR/cmd/cheat/cheat" "$APPDIR/dist/cheat"
|
|
||||||
|
|
||||||
# display a build checksum
|
|
||||||
md5sum "$APPDIR/dist/cheat"
|
|
@ -1,36 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# locate the cheat project root
|
|
||||||
BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
APPDIR=$(readlink -f "$BINDIR/..")
|
|
||||||
|
|
||||||
# update the vendored dependencies
|
|
||||||
go mod vendor && go mod tidy
|
|
||||||
|
|
||||||
# build embeds
|
|
||||||
cd "$APPDIR/cmd/cheat"
|
|
||||||
go clean && go generate
|
|
||||||
|
|
||||||
# amd64/darwin
|
|
||||||
env GOOS=darwin GOARCH=amd64 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-darwin-amd64" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
# amd64/linux
|
|
||||||
env GOOS=linux GOARCH=amd64 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-linux-amd64" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
# amd64/windows
|
|
||||||
env GOOS=windows GOARCH=amd64 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-win-amd64.exe" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
# arm7/linux
|
|
||||||
env GOOS=linux GOARCH=arm GOARM=7 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-linux-arm7" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
# arm6/linux
|
|
||||||
env GOOS=linux GOARCH=arm GOARM=6 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-linux-arm6" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
# arm5/linux
|
|
||||||
env GOOS=linux GOARCH=arm GOARM=5 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-linux-arm5" "$APPDIR/cmd/cheat"
|
|
@ -99,8 +99,15 @@ func cmdEdit(opts map[string]interface{}, conf config.Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// split `conf.Editor` into parts to separate the editor's executable from
|
||||||
|
// any arguments it may have been passed. If this is not done, the nearby
|
||||||
|
// call to `exec.Command` will fail.
|
||||||
|
parts := strings.Fields(conf.Editor)
|
||||||
|
editor := parts[0]
|
||||||
|
args := append(parts[1:], editpath)
|
||||||
|
|
||||||
// edit the cheatsheet
|
// edit the cheatsheet
|
||||||
cmd := exec.Command(conf.Editor, editpath)
|
cmd := exec.Command(editor, args...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stdin = os.Stdin
|
cmd.Stdin = os.Stdin
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/cheat/cheat/internal/config"
|
"github.com/cheat/cheat/internal/config"
|
||||||
|
"github.com/cheat/cheat/internal/sheet"
|
||||||
"github.com/cheat/cheat/internal/sheets"
|
"github.com/cheat/cheat/internal/sheets"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,6 +36,23 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||||||
// local cheatsheets)
|
// local cheatsheets)
|
||||||
consolidated := sheets.Consolidate(cheatsheets)
|
consolidated := sheets.Consolidate(cheatsheets)
|
||||||
|
|
||||||
|
// if <cheatsheet> was provided, search that single sheet only
|
||||||
|
if opts["<cheatsheet>"] != nil {
|
||||||
|
|
||||||
|
cheatsheet := opts["<cheatsheet>"].(string)
|
||||||
|
|
||||||
|
// assert that the cheatsheet exists
|
||||||
|
s, ok := consolidated[cheatsheet]
|
||||||
|
if !ok {
|
||||||
|
fmt.Printf("No cheatsheet found for '%s'.\n", cheatsheet)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
consolidated = map[string]sheet.Sheet{
|
||||||
|
cheatsheet: s,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// sort the cheatsheets alphabetically, and search for matches
|
// sort the cheatsheets alphabetically, and search for matches
|
||||||
for _, sheet := range sheets.Sort(consolidated) {
|
for _, sheet := range sheets.Sort(consolidated) {
|
||||||
|
|
||||||
@ -53,17 +71,28 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// search the sheet
|
// `Search` will return text entries that match the search terms. We're
|
||||||
matches := sheet.Search(reg, conf.Color(opts))
|
// using it here to overwrite the prior cheatsheet Text, filtering it to
|
||||||
|
// only what is relevant
|
||||||
|
sheet.Text = sheet.Search(reg)
|
||||||
|
|
||||||
// display the results
|
// if the sheet did not match the search, ignore it and move on
|
||||||
if len(matches) > 0 {
|
if sheet.Text == "" {
|
||||||
fmt.Printf("%s:\n", sheet.Title)
|
continue
|
||||||
for _, m := range matches {
|
|
||||||
fmt.Printf(" %d: %s\n", m.Line, m.Text)
|
|
||||||
}
|
|
||||||
fmt.Print("\n")
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// if colorization was requested, apply it here
|
||||||
|
if conf.Color(opts) {
|
||||||
|
sheet.Colorize(conf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// output the cheatsheet title
|
||||||
|
fmt.Printf("%s:\n", sheet.Title)
|
||||||
|
|
||||||
|
// indent each line of content with two spaces
|
||||||
|
for _, line := range strings.Split(sheet.Text, "\n") {
|
||||||
|
fmt.Printf(" %s\n", line)
|
||||||
|
}
|
||||||
|
fmt.Println("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alecthomas/chroma/quick"
|
|
||||||
|
|
||||||
"github.com/cheat/cheat/internal/config"
|
"github.com/cheat/cheat/internal/config"
|
||||||
"github.com/cheat/cheat/internal/sheets"
|
"github.com/cheat/cheat/internal/sheets"
|
||||||
)
|
)
|
||||||
@ -43,29 +41,11 @@ func cmdView(opts map[string]interface{}, conf config.Config) {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !conf.Color(opts) {
|
// apply colorization if requested
|
||||||
fmt.Print(sheet.Text)
|
if conf.Color(opts) {
|
||||||
os.Exit(0)
|
sheet.Colorize(conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, colorize the output
|
// display the cheatsheet
|
||||||
// if the syntax was not specified, default to bash
|
fmt.Print(sheet.Text)
|
||||||
lex := sheet.Syntax
|
|
||||||
if lex == "" {
|
|
||||||
lex = "bash"
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply syntax highlighting
|
|
||||||
err = quick.Highlight(
|
|
||||||
os.Stdout,
|
|
||||||
sheet.Text,
|
|
||||||
lex,
|
|
||||||
conf.Formatter,
|
|
||||||
conf.Style,
|
|
||||||
)
|
|
||||||
|
|
||||||
// if colorization somehow failed, output non-colorized text
|
|
||||||
if err != nil {
|
|
||||||
fmt.Print(sheet.Text)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/docopt/docopt-go"
|
"github.com/docopt/docopt-go"
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ import (
|
|||||||
"github.com/cheat/cheat/internal/config"
|
"github.com/cheat/cheat/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "3.2.2"
|
const version = "3.6.0"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
@ -31,13 +32,42 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the config file
|
// read the envvars into a map of strings
|
||||||
confpath, err := config.Path(runtime.GOOS)
|
envvars := map[string]string{}
|
||||||
|
for _, e := range os.Environ() {
|
||||||
|
pair := strings.SplitN(e, "=", 2)
|
||||||
|
envvars[pair[0]] = pair[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
// load the os-specifc paths at which the config file may be located
|
||||||
|
confpaths, err := config.Paths(runtime.GOOS, envvars)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "could not locate config file")
|
fmt.Fprintf(os.Stderr, "failed to load config: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search for the config file in the above paths
|
||||||
|
confpath, err := config.Path(confpaths)
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
// the config file does not exist, so we'll try to create one
|
||||||
|
if err = config.Init(confpaths[0], configs()); err != nil {
|
||||||
|
fmt.Fprintf(
|
||||||
|
os.Stderr,
|
||||||
|
"failed to create config file: %s: %v\n",
|
||||||
|
confpaths[0],
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
confpath = confpaths[0]
|
||||||
|
|
||||||
|
fmt.Printf("Created config file: %s\n", confpath)
|
||||||
|
fmt.Println("Please edit this file now to configure cheat.")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
// initialize the configs
|
// initialize the configs
|
||||||
conf, err := config.New(opts, confpath, true)
|
conf, err := config.New(opts, confpath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -43,23 +43,34 @@ cheatpaths:
|
|||||||
#
|
#
|
||||||
# Note that the paths and tags listed below are just examples. You may freely
|
# Note that the paths and tags listed below are just examples. You may freely
|
||||||
# change them to suit your needs.
|
# change them to suit your needs.
|
||||||
|
#
|
||||||
|
# TODO: regarding community cheatsheets: these must be installed separately.
|
||||||
|
# You may download them here:
|
||||||
|
#
|
||||||
|
# https://github.com/cheat/cheatsheets
|
||||||
|
#
|
||||||
|
# Once downloaded, ensure that 'path' below points to the location at which
|
||||||
|
# you downloaded the community cheatsheets.
|
||||||
- name: community
|
- name: community
|
||||||
path: ~/.dotfiles/cheat/community
|
path: ~/cheat/cheatsheets/community
|
||||||
tags: [ community ]
|
tags: [ community ]
|
||||||
readonly: true
|
readonly: true
|
||||||
|
|
||||||
# Maybe your company or department maintains a repository of cheatsheets as
|
|
||||||
# well. It's probably sensible to list those second.
|
|
||||||
- name: work
|
|
||||||
path: ~/.dotfiles/cheat/work
|
|
||||||
tags: [ work ]
|
|
||||||
readonly: false
|
|
||||||
|
|
||||||
# If you have personalized cheatsheets, list them last. They will take
|
# If you have personalized cheatsheets, list them last. They will take
|
||||||
# precedence over the more global cheatsheets.
|
# precedence over the more global cheatsheets.
|
||||||
- name: personal
|
- name: personal
|
||||||
path: ~/.dotfiles/cheat/personal
|
path: ~/cheat/cheatsheets/personal
|
||||||
tags: [ personal ]
|
tags: [ personal ]
|
||||||
readonly: false
|
readonly: false
|
||||||
|
|
||||||
|
# While it requires no specific configuration here, it's also worth noting
|
||||||
|
# that 'cheat' will automatically append directories named '.cheat' within
|
||||||
|
# the current working directory to the 'cheatpath'. This can be very useful
|
||||||
|
# if you'd like to closely associate cheatsheets with, for example, a
|
||||||
|
# directory containing source code.
|
||||||
|
#
|
||||||
|
# Such "directory-scoped" cheatsheets will be treated as the most "local"
|
||||||
|
# cheatsheets, and will override less "local" cheatsheets. Likewise,
|
||||||
|
# directory-scoped cheatsheets will always be editable ('readonly: false').
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
@ -34,21 +34,32 @@ cheatpaths:
|
|||||||
#
|
#
|
||||||
# Note that the paths and tags listed below are just examples. You may freely
|
# Note that the paths and tags listed below are just examples. You may freely
|
||||||
# change them to suit your needs.
|
# change them to suit your needs.
|
||||||
|
#
|
||||||
|
# TODO: regarding community cheatsheets: these must be installed separately.
|
||||||
|
# You may download them here:
|
||||||
|
#
|
||||||
|
# https://github.com/cheat/cheatsheets
|
||||||
|
#
|
||||||
|
# Once downloaded, ensure that 'path' below points to the location at which
|
||||||
|
# you downloaded the community cheatsheets.
|
||||||
- name: community
|
- name: community
|
||||||
path: ~/.dotfiles/cheat/community
|
path: ~/cheat/cheatsheets/community
|
||||||
tags: [ community ]
|
tags: [ community ]
|
||||||
readonly: true
|
readonly: true
|
||||||
|
|
||||||
# Maybe your company or department maintains a repository of cheatsheets as
|
|
||||||
# well. It's probably sensible to list those second.
|
|
||||||
- name: work
|
|
||||||
path: ~/.dotfiles/cheat/work
|
|
||||||
tags: [ work ]
|
|
||||||
readonly: false
|
|
||||||
|
|
||||||
# If you have personalized cheatsheets, list them last. They will take
|
# If you have personalized cheatsheets, list them last. They will take
|
||||||
# precedence over the more global cheatsheets.
|
# precedence over the more global cheatsheets.
|
||||||
- name: personal
|
- name: personal
|
||||||
path: ~/.dotfiles/cheat/personal
|
path: ~/cheat/cheatsheets/personal
|
||||||
tags: [ personal ]
|
tags: [ personal ]
|
||||||
readonly: false
|
readonly: false
|
||||||
|
|
||||||
|
# While it requires no specific configuration here, it's also worth noting
|
||||||
|
# that 'cheat' will automatically append directories named '.cheat' within
|
||||||
|
# the current working directory to the 'cheatpath'. This can be very useful
|
||||||
|
# if you'd like to closely associate cheatsheets with, for example, a
|
||||||
|
# directory containing source code.
|
||||||
|
#
|
||||||
|
# Such "directory-scoped" cheatsheets will be treated as the most "local"
|
||||||
|
# cheatsheets, and will override less "local" cheatsheets. Likewise,
|
||||||
|
# directory-scoped cheatsheets will always be editable ('readonly: false').
|
||||||
|
7
go.mod
7
go.mod
@ -3,12 +3,11 @@ module github.com/cheat/cheat
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/chroma v0.7.0
|
github.com/alecthomas/chroma v0.7.1
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
|
||||||
github.com/mattn/go-isatty v0.0.11
|
github.com/mattn/go-isatty v0.0.12
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0
|
||||||
gopkg.in/yaml.v2 v2.2.7
|
gopkg.in/yaml.v2 v2.2.8
|
||||||
)
|
)
|
||||||
|
34
go.sum
34
go.sum
@ -1,18 +1,12 @@
|
|||||||
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
|
|
||||||
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
|
|
||||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
||||||
github.com/alecthomas/chroma v0.7.0 h1:z+0HgTUmkpRDRz0SRSdMaqOLfJV4F+N1FPDZUZIDUzw=
|
github.com/alecthomas/chroma v0.7.1 h1:G1i02OhUbRi2nJxcNkwJaY/J1gHXj9tt72qN6ZouLFQ=
|
||||||
github.com/alecthomas/chroma v0.7.0/go.mod h1:1U/PfCsTALWWYHDnsIQkxEBM0+6LLe0v8+RSVMOwxeY=
|
github.com/alecthomas/chroma v0.7.1/go.mod h1:gHw09mkX1Qp80JlYbmN9L3+4R5o6DJJ3GRShh+AICNc=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
||||||
github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA=
|
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||||
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
|
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -22,25 +16,15 @@ github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg
|
|||||||
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||||
github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI=
|
|
||||||
github.com/gorilla/handlers v1.4.1/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM=
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E=
|
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
@ -50,15 +34,13 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
|
||||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||||
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
@ -2,8 +2,8 @@ package cheatpath
|
|||||||
|
|
||||||
// Cheatpath encapsulates cheatsheet path information
|
// Cheatpath encapsulates cheatsheet path information
|
||||||
type Cheatpath struct {
|
type Cheatpath struct {
|
||||||
Name string `yaml:name`
|
Name string `yaml:"name"`
|
||||||
Path string `yaml:path`
|
Path string `yaml:"path"`
|
||||||
ReadOnly bool `yaml:readonly`
|
ReadOnly bool `yaml:"readonly"`
|
||||||
Tags []string `yaml:tags`
|
Tags []string `yaml:"tags"`
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@ import (
|
|||||||
|
|
||||||
// Config encapsulates configuration parameters
|
// Config encapsulates configuration parameters
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Colorize bool `yaml:colorize`
|
Colorize bool `yaml:"colorize"`
|
||||||
Editor string `yaml:editor`
|
Editor string `yaml:"editor"`
|
||||||
Cheatpaths []cp.Cheatpath `yaml:cheatpaths`
|
Cheatpaths []cp.Cheatpath `yaml:"cheatpaths"`
|
||||||
Style string `yaml:style`
|
Style string `yaml:"style"`
|
||||||
Formatter string `yaml:formatter`
|
Formatter string `yaml:"formatter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new Config struct
|
// New returns a new Config struct
|
||||||
@ -39,6 +39,24 @@ func New(opts map[string]interface{}, confPath string, resolve bool) (Config, er
|
|||||||
return Config{}, fmt.Errorf("could not unmarshal yaml: %v", err)
|
return Config{}, fmt.Errorf("could not unmarshal yaml: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if a .cheat directory exists locally, append it to the cheatpaths
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, fmt.Errorf("failed to get cwd: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
local := filepath.Join(cwd, ".cheat")
|
||||||
|
if _, err := os.Stat(local); err == nil {
|
||||||
|
path := cp.Cheatpath{
|
||||||
|
Name: "cwd",
|
||||||
|
Path: local,
|
||||||
|
ReadOnly: false,
|
||||||
|
Tags: []string{},
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.Cheatpaths = append(conf.Cheatpaths, path)
|
||||||
|
}
|
||||||
|
|
||||||
// process cheatpaths
|
// process cheatpaths
|
||||||
for i, cheatpath := range conf.Cheatpaths {
|
for i, cheatpath := range conf.Cheatpaths {
|
||||||
|
|
||||||
@ -57,14 +75,16 @@ func New(opts map[string]interface{}, confPath string, resolve bool) (Config, er
|
|||||||
// `resolve` is a switch that allows us to turn off symlink resolution when
|
// `resolve` is a switch that allows us to turn off symlink resolution when
|
||||||
// running the config tests.
|
// running the config tests.
|
||||||
if resolve {
|
if resolve {
|
||||||
expanded, err = filepath.EvalSymlinks(expanded)
|
evaled, err := filepath.EvalSymlinks(expanded)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Config{}, fmt.Errorf(
|
return Config{}, fmt.Errorf(
|
||||||
"failed to resolve symlink: %s, %v",
|
"failed to resolve symlink: %s: %v",
|
||||||
expanded,
|
expanded,
|
||||||
err,
|
err,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expanded = evaled
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.Cheatpaths[i].Path = expanded
|
conf.Cheatpaths[i].Path = expanded
|
||||||
|
24
internal/config/init.go
Normal file
24
internal/config/init.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Init initializes a config file
|
||||||
|
func Init(confpath string, configs string) error {
|
||||||
|
|
||||||
|
// assert that the config directory exists
|
||||||
|
if err := os.MkdirAll(filepath.Dir(confpath), 0755); err != nil {
|
||||||
|
return fmt.Errorf("failed to create directory: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// write the config file
|
||||||
|
if err := ioutil.WriteFile(confpath, []byte(configs), 0644); err != nil {
|
||||||
|
return fmt.Errorf("failed to create file: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
@ -3,58 +3,10 @@ package config
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
|
|
||||||
"github.com/mitchellh/go-homedir"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Path returns the config file path
|
// Path returns the config file path
|
||||||
func Path(sys string) (string, error) {
|
func Path(paths []string) (string, error) {
|
||||||
|
|
||||||
var paths []string
|
|
||||||
|
|
||||||
// if CHEAT_CONFIG_PATH is set, return it
|
|
||||||
if os.Getenv("CHEAT_CONFIG_PATH") != "" {
|
|
||||||
|
|
||||||
// expand ~
|
|
||||||
expanded, err := homedir.Expand(os.Getenv("CHEAT_CONFIG_PATH"))
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("failed to expand ~: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return expanded, nil
|
|
||||||
|
|
||||||
// OSX config paths
|
|
||||||
} else if sys == "darwin" {
|
|
||||||
|
|
||||||
paths = []string{
|
|
||||||
path.Join(os.Getenv("XDG_CONFIG_HOME"), "/cheat/conf.yml"),
|
|
||||||
path.Join(os.Getenv("HOME"), ".config/cheat/conf.yml"),
|
|
||||||
path.Join(os.Getenv("HOME"), ".cheat/conf.yml"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Linux config paths
|
|
||||||
} else if sys == "linux" {
|
|
||||||
|
|
||||||
paths = []string{
|
|
||||||
path.Join(os.Getenv("XDG_CONFIG_HOME"), "/cheat/conf.yml"),
|
|
||||||
path.Join(os.Getenv("HOME"), ".config/cheat/conf.yml"),
|
|
||||||
path.Join(os.Getenv("HOME"), ".cheat/conf.yml"),
|
|
||||||
"/etc/cheat/conf.yml",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Windows config paths
|
|
||||||
} else if sys == "windows" {
|
|
||||||
|
|
||||||
paths = []string{
|
|
||||||
fmt.Sprintf("%s/cheat/conf.yml", os.Getenv("APPDATA")),
|
|
||||||
fmt.Sprintf("%s/cheat/conf.yml", os.Getenv("PROGRAMDATA")),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unsupported platforms
|
|
||||||
} else {
|
|
||||||
return "", fmt.Errorf("unsupported os: %s", sys)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the config file exists on any paths
|
// check if the config file exists on any paths
|
||||||
for _, p := range paths {
|
for _, p := range paths {
|
||||||
|
50
internal/config/paths.go
Normal file
50
internal/config/paths.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"github.com/mitchellh/go-homedir"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Paths returns config file paths that are appropriate for the operating
|
||||||
|
// system
|
||||||
|
func Paths(sys string, envvars map[string]string) ([]string, error) {
|
||||||
|
|
||||||
|
// if `CHEAT_CONFIG_PATH` is set, expand ~ and return it
|
||||||
|
if confpath, ok := envvars["CHEAT_CONFIG_PATH"]; ok {
|
||||||
|
|
||||||
|
// expand ~
|
||||||
|
expanded, err := homedir.Expand(confpath)
|
||||||
|
if err != nil {
|
||||||
|
return []string{}, fmt.Errorf("failed to expand ~: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return []string{expanded}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
switch sys {
|
||||||
|
case "darwin", "linux", "freebsd":
|
||||||
|
paths := []string{}
|
||||||
|
|
||||||
|
// don't include the `XDG_CONFIG_HOME` path if that envvar is not set
|
||||||
|
if xdgpath, ok := envvars["XDG_CONFIG_HOME"]; ok {
|
||||||
|
paths = append(paths, path.Join(xdgpath, "/cheat/conf.yml"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// `HOME` will always be set on a POSIX-compliant system, though
|
||||||
|
paths = append(paths, []string{
|
||||||
|
path.Join(envvars["HOME"], ".config/cheat/conf.yml"),
|
||||||
|
path.Join(envvars["HOME"], ".cheat/conf.yml"),
|
||||||
|
}...)
|
||||||
|
|
||||||
|
return paths, nil
|
||||||
|
case "windows":
|
||||||
|
return []string{
|
||||||
|
path.Join(envvars["APPDATA"], "/cheat/conf.yml"),
|
||||||
|
path.Join(envvars["PROGRAMDATA"], "/cheat/conf.yml"),
|
||||||
|
}, nil
|
||||||
|
default:
|
||||||
|
return []string{}, fmt.Errorf("unsupported os: %s", sys)
|
||||||
|
}
|
||||||
|
}
|
165
internal/config/paths_test.go
Normal file
165
internal/config/paths_test.go
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestValidatePathsNix asserts that the proper config paths are returned on
|
||||||
|
// *nix platforms
|
||||||
|
func TestValidatePathsNix(t *testing.T) {
|
||||||
|
|
||||||
|
// mock some envvars
|
||||||
|
envvars := map[string]string{
|
||||||
|
"HOME": "/home/foo",
|
||||||
|
"XDG_CONFIG_HOME": "/home/bar",
|
||||||
|
}
|
||||||
|
|
||||||
|
// specify the platforms to test
|
||||||
|
oses := []string{
|
||||||
|
"darwin",
|
||||||
|
"freebsd",
|
||||||
|
"linux",
|
||||||
|
}
|
||||||
|
|
||||||
|
// test each *nix os
|
||||||
|
for _, os := range oses {
|
||||||
|
// get the paths for the platform
|
||||||
|
paths, err := Paths(os, envvars)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("paths returned an error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// specify the expected output
|
||||||
|
want := []string{
|
||||||
|
"/home/bar/cheat/conf.yml",
|
||||||
|
"/home/foo/.config/cheat/conf.yml",
|
||||||
|
"/home/foo/.cheat/conf.yml",
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert that output matches expectations
|
||||||
|
if !reflect.DeepEqual(paths, want) {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to return expected paths: want:\n%s, got:\n%s",
|
||||||
|
spew.Sdump(want),
|
||||||
|
spew.Sdump(paths),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestValidatePathsNixNoXDG asserts that the proper config paths are returned
|
||||||
|
// on *nix platforms when `XDG_CONFIG_HOME is not set
|
||||||
|
func TestValidatePathsNixNoXDG(t *testing.T) {
|
||||||
|
|
||||||
|
// mock some envvars
|
||||||
|
envvars := map[string]string{
|
||||||
|
"HOME": "/home/foo",
|
||||||
|
}
|
||||||
|
|
||||||
|
// specify the platforms to test
|
||||||
|
oses := []string{
|
||||||
|
"darwin",
|
||||||
|
"freebsd",
|
||||||
|
"linux",
|
||||||
|
}
|
||||||
|
|
||||||
|
// test each *nix os
|
||||||
|
for _, os := range oses {
|
||||||
|
// get the paths for the platform
|
||||||
|
paths, err := Paths(os, envvars)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("paths returned an error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// specify the expected output
|
||||||
|
want := []string{
|
||||||
|
"/home/foo/.config/cheat/conf.yml",
|
||||||
|
"/home/foo/.cheat/conf.yml",
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert that output matches expectations
|
||||||
|
if !reflect.DeepEqual(paths, want) {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to return expected paths: want:\n%s, got:\n%s",
|
||||||
|
spew.Sdump(want),
|
||||||
|
spew.Sdump(paths),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestValidatePathsWindows asserts that the proper config paths are returned
|
||||||
|
// on Windows platforms
|
||||||
|
func TestValidatePathsWindows(t *testing.T) {
|
||||||
|
|
||||||
|
// mock some envvars
|
||||||
|
envvars := map[string]string{
|
||||||
|
"APPDATA": "/apps",
|
||||||
|
"PROGRAMDATA": "/programs",
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the paths for the platform
|
||||||
|
paths, err := Paths("windows", envvars)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("paths returned an error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// specify the expected output
|
||||||
|
want := []string{
|
||||||
|
"/apps/cheat/conf.yml",
|
||||||
|
"/programs/cheat/conf.yml",
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert that output matches expectations
|
||||||
|
if !reflect.DeepEqual(paths, want) {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to return expected paths: want:\n%s, got:\n%s",
|
||||||
|
spew.Sdump(want),
|
||||||
|
spew.Sdump(paths),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestValidatePathsUnsupported asserts that an error is returned on
|
||||||
|
// unsupported platforms
|
||||||
|
func TestValidatePathsUnsupported(t *testing.T) {
|
||||||
|
_, err := Paths("unsupported", map[string]string{})
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("failed to return error on unsupported platform")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestValidatePathsCheatConfigPath asserts that the proper config path is
|
||||||
|
// returned when `CHEAT_CONFIG_PATH` is explicitly specified.
|
||||||
|
func TestValidatePathsCheatConfigPath(t *testing.T) {
|
||||||
|
|
||||||
|
// mock some envvars
|
||||||
|
envvars := map[string]string{
|
||||||
|
"HOME": "/home/foo",
|
||||||
|
"XDG_CONFIG_HOME": "/home/bar",
|
||||||
|
"CHEAT_CONFIG_PATH": "/home/baz/conf.yml",
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the paths for the platform
|
||||||
|
paths, err := Paths("linux", envvars)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("paths returned an error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// specify the expected output
|
||||||
|
want := []string{
|
||||||
|
"/home/baz/conf.yml",
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert that output matches expectations
|
||||||
|
if !reflect.DeepEqual(paths, want) {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to return expected paths: want:\n%s, got:\n%s",
|
||||||
|
spew.Sdump(want),
|
||||||
|
spew.Sdump(paths),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
37
internal/sheet/colorize.go
Normal file
37
internal/sheet/colorize.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package sheet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/cheat/cheat/internal/config"
|
||||||
|
|
||||||
|
"github.com/alecthomas/chroma/quick"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Colorize applies syntax-highlighting to a cheatsheet's Text.
|
||||||
|
func (s *Sheet) Colorize(conf config.Config) {
|
||||||
|
|
||||||
|
// if the syntax was not specified, default to bash
|
||||||
|
lex := s.Syntax
|
||||||
|
if lex == "" {
|
||||||
|
lex = "bash"
|
||||||
|
}
|
||||||
|
|
||||||
|
// write colorized text into a buffer
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err := quick.Highlight(
|
||||||
|
&buf,
|
||||||
|
s.Text,
|
||||||
|
lex,
|
||||||
|
conf.Formatter,
|
||||||
|
conf.Style,
|
||||||
|
)
|
||||||
|
|
||||||
|
// if colorization somehow failed, do nothing
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, swap the cheatsheet's Text with its colorized equivalent
|
||||||
|
s.Text = buf.String()
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
package sheet
|
|
||||||
|
|
||||||
// Match encapsulates search matches within cheatsheets
|
|
||||||
type Match struct {
|
|
||||||
Line int
|
|
||||||
Text string
|
|
||||||
}
|
|
@ -3,43 +3,22 @@ package sheet
|
|||||||
import (
|
import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mgutz/ansi"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Search searches for regexp matches in a cheatsheet's text, and optionally
|
// Search returns lines within a sheet's Text that match the search regex
|
||||||
// colorizes matching strings.
|
func (s *Sheet) Search(reg *regexp.Regexp) string {
|
||||||
func (s *Sheet) Search(reg *regexp.Regexp, colorize bool) []Match {
|
|
||||||
|
|
||||||
// record matches
|
// record matches
|
||||||
matches := []Match{}
|
matches := ""
|
||||||
|
|
||||||
// search through the cheatsheet's text line by line
|
// search through the cheatsheet's text line by line
|
||||||
// TODO: searching line-by-line is surely the "naive" approach. Revisit this
|
for _, line := range strings.Split(s.Text, "\n\n") {
|
||||||
// later with an eye for performance improvements.
|
|
||||||
for linenum, line := range strings.Split(s.Text, "\n") {
|
|
||||||
|
|
||||||
// exit early if the line doesn't match the regex
|
// exit early if the line doesn't match the regex
|
||||||
if !reg.MatchString(line) {
|
if reg.MatchString(line) {
|
||||||
continue
|
matches += line + "\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
// init the match
|
|
||||||
m := Match{
|
|
||||||
Line: linenum + 1,
|
|
||||||
Text: strings.TrimSpace(line),
|
|
||||||
}
|
|
||||||
|
|
||||||
// colorize the matching text if so configured
|
|
||||||
if colorize {
|
|
||||||
m.Text = reg.ReplaceAllStringFunc(m.Text, func(matched string) string {
|
|
||||||
return ansi.Color(matched, "red+b")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// record the match
|
|
||||||
matches = append(matches, m)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches
|
return strings.TrimSpace(matches)
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestSearchNoMatch ensures that the expected output is returned when no
|
// TestSearchNoMatch ensures that the expected output is returned when no
|
||||||
@ -24,21 +22,21 @@ func TestSearchNoMatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search the sheet
|
// search the sheet
|
||||||
matches := sheet.Search(reg, false)
|
matches := sheet.Search(reg)
|
||||||
|
|
||||||
// assert that no matches were found
|
// assert that no matches were found
|
||||||
if len(matches) != 0 {
|
if matches != "" {
|
||||||
t.Errorf("failure: expected no matches: got: %s", spew.Sdump(matches))
|
t.Errorf("failure: expected no matches: got: %s", matches)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestSearchSingleMatchNoColor asserts that the expected output is returned
|
// TestSearchSingleMatch asserts that the expected output is returned
|
||||||
// when a single match is returned, and no colorization is applied.
|
// when a single match is returned
|
||||||
func TestSearchSingleMatchNoColor(t *testing.T) {
|
func TestSearchSingleMatch(t *testing.T) {
|
||||||
|
|
||||||
// mock a cheatsheet
|
// mock a cheatsheet
|
||||||
sheet := Sheet{
|
sheet := Sheet{
|
||||||
Text: "The quick brown fox\njumped over\nthe lazy dog.",
|
Text: "The quick brown fox\njumped over\n\nthe lazy dog.",
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile the search regex
|
// compile the search regex
|
||||||
@ -48,69 +46,28 @@ func TestSearchSingleMatchNoColor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search the sheet
|
// search the sheet
|
||||||
matches := sheet.Search(reg, false)
|
matches := sheet.Search(reg)
|
||||||
|
|
||||||
// specify the expected results
|
// specify the expected results
|
||||||
want := []Match{
|
want := "The quick brown fox\njumped over"
|
||||||
Match{
|
|
||||||
Line: 1,
|
|
||||||
Text: "The quick brown fox",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert that the correct matches were returned
|
// assert that the correct matches were returned
|
||||||
if !reflect.DeepEqual(matches, want) {
|
if matches != want {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"failed to return expected matches: want:\n%s, got:\n%s",
|
"failed to return expected matches: want:\n%s, got:\n%s",
|
||||||
spew.Sdump(want),
|
want,
|
||||||
spew.Sdump(matches),
|
matches,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestSearchSingleMatchColorized asserts that the expected output is returned
|
// TestSearchMultiMatch asserts that the expected output is returned
|
||||||
// when a single match is returned, and colorization is applied
|
// when a multiple matches are returned
|
||||||
func TestSearchSingleMatchColorized(t *testing.T) {
|
func TestSearchMultiMatch(t *testing.T) {
|
||||||
|
|
||||||
// mock a cheatsheet
|
// mock a cheatsheet
|
||||||
sheet := Sheet{
|
sheet := Sheet{
|
||||||
Text: "The quick brown fox\njumped over\nthe lazy dog.",
|
Text: "The quick brown fox\n\njumped over\n\nthe lazy dog.",
|
||||||
}
|
|
||||||
|
|
||||||
// compile the search regex
|
|
||||||
reg, err := regexp.Compile("(?i)fox")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to compile regex: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// search the sheet
|
|
||||||
matches := sheet.Search(reg, true)
|
|
||||||
|
|
||||||
// specify the expected results
|
|
||||||
want := []Match{
|
|
||||||
Match{
|
|
||||||
Line: 1,
|
|
||||||
Text: "The quick brown \x1b[1;31mfox\x1b[0m",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert that the correct matches were returned
|
|
||||||
if !reflect.DeepEqual(matches, want) {
|
|
||||||
t.Errorf(
|
|
||||||
"failed to return expected matches: want:\n%s, got:\n%s",
|
|
||||||
spew.Sdump(want),
|
|
||||||
spew.Sdump(matches),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSearchMultiMatchNoColor asserts that the expected output is returned
|
|
||||||
// when a multiple matches are returned, and no colorization is applied
|
|
||||||
func TestSearchMultiMatchNoColor(t *testing.T) {
|
|
||||||
|
|
||||||
// mock a cheatsheet
|
|
||||||
sheet := Sheet{
|
|
||||||
Text: "The quick brown fox\njumped over\nthe lazy dog.",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile the search regex
|
// compile the search regex
|
||||||
@ -120,66 +77,17 @@ func TestSearchMultiMatchNoColor(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search the sheet
|
// search the sheet
|
||||||
matches := sheet.Search(reg, false)
|
matches := sheet.Search(reg)
|
||||||
|
|
||||||
// specify the expected results
|
// specify the expected results
|
||||||
want := []Match{
|
want := "The quick brown fox\n\nthe lazy dog."
|
||||||
Match{
|
|
||||||
Line: 1,
|
|
||||||
Text: "The quick brown fox",
|
|
||||||
},
|
|
||||||
Match{
|
|
||||||
Line: 3,
|
|
||||||
Text: "the lazy dog.",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert that the correct matches were returned
|
// assert that the correct matches were returned
|
||||||
if !reflect.DeepEqual(matches, want) {
|
if !reflect.DeepEqual(matches, want) {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"failed to return expected matches: want:\n%s, got:\n%s",
|
"failed to return expected matches: want:\n%s, got:\n%s",
|
||||||
spew.Sdump(want),
|
want,
|
||||||
spew.Sdump(matches),
|
matches,
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSearchMultiMatchColorized asserts that the expected output is returned
|
|
||||||
// when a multiple matches are returned, and colorization is applied
|
|
||||||
func TestSearchMultiMatchColorized(t *testing.T) {
|
|
||||||
|
|
||||||
// mock a cheatsheet
|
|
||||||
sheet := Sheet{
|
|
||||||
Text: "The quick brown fox\njumped over\nthe lazy dog.",
|
|
||||||
}
|
|
||||||
|
|
||||||
// compile the search regex
|
|
||||||
reg, err := regexp.Compile("(?i)the")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to compile regex: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// search the sheet
|
|
||||||
matches := sheet.Search(reg, true)
|
|
||||||
|
|
||||||
// specify the expected results
|
|
||||||
want := []Match{
|
|
||||||
Match{
|
|
||||||
Line: 1,
|
|
||||||
Text: "\x1b[1;31mThe\x1b[0m quick brown fox",
|
|
||||||
},
|
|
||||||
Match{
|
|
||||||
Line: 3,
|
|
||||||
Text: "\x1b[1;31mthe\x1b[0m lazy dog.",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// assert that the correct matches were returned
|
|
||||||
if !reflect.DeepEqual(matches, want) {
|
|
||||||
t.Errorf(
|
|
||||||
"failed to return expected matches: want:\n%s, got:\n%s",
|
|
||||||
spew.Sdump(want),
|
|
||||||
spew.Sdump(matches),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
function _cheat_autocomplete {
|
|
||||||
sheets=$(cheat -l | sed -n '2,$p'|cut -d' ' -f1)
|
|
||||||
COMPREPLY=()
|
|
||||||
if [ $COMP_CWORD = 1 ]; then
|
|
||||||
COMPREPLY=(`compgen -W "$sheets" -- $2`)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
complete -F _cheat_autocomplete cheat
|
|
74
scripts/cheat.bash
Executable file
74
scripts/cheat.bash
Executable file
@ -0,0 +1,74 @@
|
|||||||
|
# cheat(1) completion -*- shell-script -*-
|
||||||
|
|
||||||
|
# generate cheatsheet completions, optionally using `fzf`
|
||||||
|
_cheat_complete_cheatsheets()
|
||||||
|
{
|
||||||
|
if [[ "$CHEAT_USE_FZF" = true ]]; then
|
||||||
|
FZF_COMPLETION_TRIGGER='' _fzf_complete "--no-multi" "$@" < <(
|
||||||
|
cheat -l | tail -n +2 | cut -d' ' -f1
|
||||||
|
)
|
||||||
|
else
|
||||||
|
COMPREPLY=( $(compgen -W "$(cheat -l | tail -n +2 | cut -d' ' -f1)" -- "$cur") )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# generate tag completions, optionally using `fzf`
|
||||||
|
_cheat_complete_tags()
|
||||||
|
{
|
||||||
|
if [ "$CHEAT_USE_FZF" = true ]; then
|
||||||
|
FZF_COMPLETION_TRIGGER='' _fzf_complete "--no-multi" "$@" < <(cheat -T)
|
||||||
|
else
|
||||||
|
COMPREPLY=( $(compgen -W "$(cheat -T)" -- "$cur") )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# implement the `cheat` autocompletions
|
||||||
|
_cheat()
|
||||||
|
{
|
||||||
|
local cur prev words cword split
|
||||||
|
_init_completion -s || return
|
||||||
|
|
||||||
|
# complete options that are currently being typed: `--col` => `--colorize`
|
||||||
|
if [[ $cur == -* ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W '$(_parse_help "$1" | sed "s/=//g")' -- "$cur") )
|
||||||
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# implement completions
|
||||||
|
case $prev in
|
||||||
|
--colorize|-c|\
|
||||||
|
--directories|-d|\
|
||||||
|
--init|\
|
||||||
|
--regex|-r|\
|
||||||
|
--search|-s|\
|
||||||
|
--tags|-T|\
|
||||||
|
--version|-v)
|
||||||
|
# noop the above, which should implement no completions
|
||||||
|
;;
|
||||||
|
--edit|-e)
|
||||||
|
_cheat_complete_cheatsheets
|
||||||
|
;;
|
||||||
|
--list|-l)
|
||||||
|
_cheat_complete_cheatsheets
|
||||||
|
;;
|
||||||
|
--path|-p)
|
||||||
|
COMPREPLY=( $(compgen -W "$(cheat -d | cut -d':' -f1)" -- "$cur") )
|
||||||
|
;;
|
||||||
|
--rm)
|
||||||
|
_cheat_complete_cheatsheets
|
||||||
|
;;
|
||||||
|
--tag|-t)
|
||||||
|
_cheat_complete_tags
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_cheat_complete_cheatsheets
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
$split && return
|
||||||
|
|
||||||
|
} &&
|
||||||
|
complete -F _cheat cheat
|
||||||
|
|
||||||
|
# ex: filetype=sh
|
@ -1,11 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This function enables you to choose a cheatsheet to view by selecting output
|
|
||||||
# from `cheat -l`. `source` it in your shell to enable it. (Consider renaming
|
|
||||||
# or aliasing it to something convenient.)
|
|
||||||
|
|
||||||
# Arguments passed to this function (like --color) will be passed to the second
|
|
||||||
# invokation of `cheat`.
|
|
||||||
function cheat-fzf {
|
|
||||||
eval `cheat -l | tail -n +2 | fzf | awk -v vars="$*" '{ print "cheat " $1 " -t " $3, vars }'`
|
|
||||||
}
|
|
4
vendor/github.com/alecthomas/chroma/.golangci.yml
generated
vendored
4
vendor/github.com/alecthomas/chroma/.golangci.yml
generated
vendored
@ -18,6 +18,8 @@ linters:
|
|||||||
- funlen
|
- funlen
|
||||||
- godox
|
- godox
|
||||||
- wsl
|
- wsl
|
||||||
|
- gomnd
|
||||||
|
- gocognit
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
govet:
|
||||||
@ -49,3 +51,5 @@ issues:
|
|||||||
- 'at least one file in a package should have a package comment'
|
- 'at least one file in a package should have a package comment'
|
||||||
- 'string literal contains the Unicode'
|
- 'string literal contains the Unicode'
|
||||||
- 'methods on the same type should have the same receiver name'
|
- 'methods on the same type should have the same receiver name'
|
||||||
|
- '_TokenType_name should be _TokenTypeName'
|
||||||
|
- '`_TokenType_map` should be `_TokenTypeMap`'
|
||||||
|
4
vendor/github.com/alecthomas/chroma/.travis.yml
generated
vendored
4
vendor/github.com/alecthomas/chroma/.travis.yml
generated
vendored
@ -1,8 +1,10 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
language: go
|
language: go
|
||||||
|
go:
|
||||||
|
- "1.13.x"
|
||||||
script:
|
script:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.20.0
|
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.22.2
|
||||||
- ./bin/golangci-lint run
|
- ./bin/golangci-lint run
|
||||||
- git clean -fdx .
|
- git clean -fdx .
|
||||||
after_success:
|
after_success:
|
||||||
|
19
vendor/github.com/alecthomas/chroma/Makefile
generated
vendored
Normal file
19
vendor/github.com/alecthomas/chroma/Makefile
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.PHONY: chromad upload all
|
||||||
|
|
||||||
|
all: README.md tokentype_string.go
|
||||||
|
|
||||||
|
README.md: lexers/*/*.go
|
||||||
|
./table.py
|
||||||
|
|
||||||
|
tokentype_string.go: types.go
|
||||||
|
go generate
|
||||||
|
|
||||||
|
chromad:
|
||||||
|
(cd ./cmd/chromad && go get github.com/GeertJohan/go.rice/rice@master && go install github.com/GeertJohan/go.rice/rice)
|
||||||
|
rm -f chromad
|
||||||
|
(export CGOENABLED=0 GOOS=linux ; cd ./cmd/chromad && go build -o ../../chromad .)
|
||||||
|
rice append -i ./cmd/chromad --exec=./chromad
|
||||||
|
|
||||||
|
upload: chromad
|
||||||
|
scp chromad root@swapoff.org: && \
|
||||||
|
ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
|
7
vendor/github.com/alecthomas/chroma/README.md
generated
vendored
7
vendor/github.com/alecthomas/chroma/README.md
generated
vendored
@ -47,14 +47,14 @@ I | Idris, INI, Io
|
|||||||
J | J, Java, JavaScript, JSON, Julia, Jungle
|
J | J, Java, JavaScript, JSON, Julia, Jungle
|
||||||
K | Kotlin
|
K | Kotlin
|
||||||
L | Lighttpd configuration file, LLVM, Lua
|
L | Lighttpd configuration file, LLVM, Lua
|
||||||
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
|
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
|
||||||
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
|
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
|
||||||
O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
|
O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
|
||||||
P | PacmanConf, Perl, PHP, Pig, PkgConfig, PL/pgSQL, plaintext, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3
|
P | PacmanConf, Perl, PHP, Pig, PkgConfig, PL/pgSQL, plaintext, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3
|
||||||
Q | QBasic
|
Q | QBasic
|
||||||
R | R, Racket, Ragel, react, reg, reStructuredText, Rexx, Ruby, Rust
|
R | R, Racket, Ragel, react, reg, reStructuredText, Rexx, Ruby, Rust
|
||||||
S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, SYSTEMD, systemverilog
|
S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, SML, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, SYSTEMD, systemverilog
|
||||||
T | TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
|
T | TableGen, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
|
||||||
V | VB.net, verilog, VHDL, VimL, vue
|
V | VB.net, verilog, VHDL, VimL, vue
|
||||||
W | WDTE
|
W | WDTE
|
||||||
X | XML, Xorg
|
X | XML, Xorg
|
||||||
@ -183,6 +183,7 @@ following constructor options:
|
|||||||
- `ClassPrefix(prefix)` - prefix each generated CSS class.
|
- `ClassPrefix(prefix)` - prefix each generated CSS class.
|
||||||
- `TabWidth(width)` - Set the rendered tab width, in characters.
|
- `TabWidth(width)` - Set the rendered tab width, in characters.
|
||||||
- `WithLineNumbers()` - Render line numbers (style with `LineNumbers`).
|
- `WithLineNumbers()` - Render line numbers (style with `LineNumbers`).
|
||||||
|
- `LinkableLineNumbers()` - Make the line numbers linkable.
|
||||||
- `HighlightLines(ranges)` - Highlight lines in these ranges (style with `LineHighlight`).
|
- `HighlightLines(ranges)` - Highlight lines in these ranges (style with `LineHighlight`).
|
||||||
- `LineNumbersInTable()` - Use a table for formatting line numbers and code, rather than spans.
|
- `LineNumbersInTable()` - Use a table for formatting line numbers and code, rather than spans.
|
||||||
|
|
||||||
|
47
vendor/github.com/alecthomas/chroma/formatters/html/html.go
generated
vendored
47
vendor/github.com/alecthomas/chroma/formatters/html/html.go
generated
vendored
@ -58,6 +58,15 @@ func LineNumbersInTable(b bool) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LinkableLineNumbers decorates the line numbers HTML elements with an "id"
|
||||||
|
// attribute so they can be linked.
|
||||||
|
func LinkableLineNumbers(b bool, prefix string) Option {
|
||||||
|
return func(f *Formatter) {
|
||||||
|
f.linkableLineNumbers = b
|
||||||
|
f.lineNumbersIDPrefix = prefix
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// HighlightLines higlights the given line ranges with the Highlight style.
|
// HighlightLines higlights the given line ranges with the Highlight style.
|
||||||
//
|
//
|
||||||
// A range is the beginning and ending of a range as 1-based line numbers, inclusive.
|
// A range is the beginning and ending of a range as 1-based line numbers, inclusive.
|
||||||
@ -129,15 +138,17 @@ var (
|
|||||||
|
|
||||||
// Formatter that generates HTML.
|
// Formatter that generates HTML.
|
||||||
type Formatter struct {
|
type Formatter struct {
|
||||||
standalone bool
|
standalone bool
|
||||||
prefix string
|
prefix string
|
||||||
Classes bool // Exported field to detect when classes are being used
|
Classes bool // Exported field to detect when classes are being used
|
||||||
preWrapper PreWrapper
|
preWrapper PreWrapper
|
||||||
tabWidth int
|
tabWidth int
|
||||||
lineNumbers bool
|
lineNumbers bool
|
||||||
lineNumbersInTable bool
|
lineNumbersInTable bool
|
||||||
highlightRanges highlightRanges
|
linkableLineNumbers bool
|
||||||
baseLineNumber int
|
lineNumbersIDPrefix string
|
||||||
|
highlightRanges highlightRanges
|
||||||
|
baseLineNumber int
|
||||||
}
|
}
|
||||||
|
|
||||||
type highlightRanges [][2]int
|
type highlightRanges [][2]int
|
||||||
@ -196,7 +207,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
fmt.Fprintf(w, "<span%s>", f.styleAttr(css, chroma.LineHighlight))
|
fmt.Fprintf(w, "<span%s>", f.styleAttr(css, chroma.LineHighlight))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "<span%s>%*d\n</span>", f.styleAttr(css, chroma.LineNumbersTable), lineDigits, line)
|
fmt.Fprintf(w, "<span%s%s>%*d\n</span>", f.styleAttr(css, chroma.LineNumbersTable), f.lineIDAttribute(line), lineDigits, line)
|
||||||
|
|
||||||
if highlight {
|
if highlight {
|
||||||
fmt.Fprintf(w, "</span>")
|
fmt.Fprintf(w, "</span>")
|
||||||
@ -222,7 +233,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if f.lineNumbers && !wrapInTable {
|
if f.lineNumbers && !wrapInTable {
|
||||||
fmt.Fprintf(w, "<span%s>%*d</span>", f.styleAttr(css, chroma.LineNumbers), lineDigits, line)
|
fmt.Fprintf(w, "<span%s%s>%*d</span>", f.styleAttr(css, chroma.LineNumbers), f.lineIDAttribute(line), lineDigits, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
@ -253,6 +264,13 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) lineIDAttribute(line int) string {
|
||||||
|
if !f.linkableLineNumbers {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(" id=\"%s%d\"", f.lineNumbersIDPrefix, line)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Formatter) shouldHighlight(highlightIndex, line int) (bool, bool) {
|
func (f *Formatter) shouldHighlight(highlightIndex, line int) (bool, bool) {
|
||||||
next := false
|
next := false
|
||||||
for highlightIndex < len(f.highlightRanges) && line > f.highlightRanges[highlightIndex][1] {
|
for highlightIndex < len(f.highlightRanges) && line > f.highlightRanges[highlightIndex][1] {
|
||||||
@ -327,6 +345,13 @@ func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Special-case line number highlighting when targeted.
|
||||||
|
if f.lineNumbers || f.lineNumbersInTable {
|
||||||
|
targetedLineCSS := StyleEntryToCSS(style.Get(chroma.LineHighlight))
|
||||||
|
for _, tt := range []chroma.TokenType{chroma.LineNumbers, chroma.LineNumbersTable} {
|
||||||
|
fmt.Fprintf(w, "/* %s targeted by URL anchor */ .%schroma .%s:target { %s }\n", tt, f.prefix, f.class(tt), targetedLineCSS)
|
||||||
|
}
|
||||||
|
}
|
||||||
tts := []int{}
|
tts := []int{}
|
||||||
for tt := range css {
|
for tt := range css {
|
||||||
tts = append(tts, int(tt))
|
tts = append(tts, int(tt))
|
||||||
|
5
vendor/github.com/alecthomas/chroma/go.mod
generated
vendored
5
vendor/github.com/alecthomas/chroma/go.mod
generated
vendored
@ -1,17 +1,12 @@
|
|||||||
module github.com/alecthomas/chroma
|
module github.com/alecthomas/chroma
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/GeertJohan/go.rice v1.0.0
|
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8
|
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
|
||||||
github.com/dlclark/regexp2 v1.1.6
|
github.com/dlclark/regexp2 v1.1.6
|
||||||
github.com/gorilla/csrf v1.6.0
|
|
||||||
github.com/gorilla/handlers v1.4.1
|
|
||||||
github.com/gorilla/mux v1.7.3
|
|
||||||
github.com/mattn/go-colorable v0.0.9
|
github.com/mattn/go-colorable v0.0.9
|
||||||
github.com/mattn/go-isatty v0.0.4
|
github.com/mattn/go-isatty v0.0.4
|
||||||
github.com/sergi/go-diff v1.0.0 // indirect
|
github.com/sergi/go-diff v1.0.0 // indirect
|
||||||
|
25
vendor/github.com/alecthomas/chroma/go.sum
generated
vendored
25
vendor/github.com/alecthomas/chroma/go.sum
generated
vendored
@ -1,20 +1,11 @@
|
|||||||
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
|
|
||||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
||||||
github.com/alecthomas/go.rice v1.0.1-0.20190719113735-961b99d742e7 h1:0cMlP9evwgTzs5JUe2C/3rLttYjmRm0kbz9fdGBIV1E=
|
|
||||||
github.com/alecthomas/go.rice v1.0.1-0.20190719113735-961b99d742e7/go.mod h1:af5vUNlDNkCjOZeSGFgIJxDje9qdjsO6hshx0gTmZt4=
|
|
||||||
github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae h1:C4Q9m+oXOxcSWwYk9XzzafY2xAVAaeubZbUHJkw3PlY=
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae h1:C4Q9m+oXOxcSWwYk9XzzafY2xAVAaeubZbUHJkw3PlY=
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8 h1:atLL+K8Hg0e8863K2X+k7qu+xz3M2a/mWFIACAPf55M=
|
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA=
|
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||||
github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY=
|
|
||||||
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
|
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -22,25 +13,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
|
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
|
||||||
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||||
github.com/gorilla/csrf v1.6.0 h1:60oN1cFdncCE8tjwQ3QEkFND5k37lQPcRjnlvm7CIJ0=
|
|
||||||
github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI=
|
|
||||||
github.com/gorilla/handlers v1.4.1 h1:BHvcRGJe/TrL+OqFxoKQGddTgeibiOjaBssV5a/N9sw=
|
|
||||||
github.com/gorilla/handlers v1.4.1/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
|
||||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/nkovacs/streamquote v1.0.0/go.mod h1:BN+NaZ2CmdKqUuTUXUEm9j95B2TRbpOWpxbJYzzgUsc=
|
|
||||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@ -52,7 +29,5 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1
|
|||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
|
||||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
43
vendor/github.com/alecthomas/chroma/lexers/m/mlir.go
generated
vendored
Normal file
43
vendor/github.com/alecthomas/chroma/lexers/m/mlir.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package m
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MLIR lexer.
|
||||||
|
var Mlir = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "MLIR",
|
||||||
|
Aliases: []string{"mlir"},
|
||||||
|
Filenames: []string{"*.mlir"},
|
||||||
|
MimeTypes: []string{"text/x-mlir"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`c?"[^"]*?"`, LiteralString, nil},
|
||||||
|
{`\^([-a-zA-Z$._][\w\-$.0-9]*)\s*`, NameLabel, nil},
|
||||||
|
{`([\w\d_$.]+)\s*=`, NameLabel, nil},
|
||||||
|
Include("keyword"),
|
||||||
|
{`->`, Punctuation, nil},
|
||||||
|
{`@([\w_][\w\d_$.]*)`, NameFunction, nil},
|
||||||
|
{`[%#][\w\d_$.]+`, NameVariable, nil},
|
||||||
|
{`([1-9?][\d?]*\s*x)+`, LiteralNumber, nil},
|
||||||
|
{`0[xX][a-fA-F0-9]+`, LiteralNumber, nil},
|
||||||
|
{`-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?`, LiteralNumber, nil},
|
||||||
|
{`[=<>{}\[\]()*.,!:]|x\b`, Punctuation, nil},
|
||||||
|
{`[\w\d]+`, Text, nil},
|
||||||
|
},
|
||||||
|
"whitespace": {
|
||||||
|
{`(\n|\s)+`, Text, nil},
|
||||||
|
{`//.*?\n`, Comment, nil},
|
||||||
|
},
|
||||||
|
"keyword": {
|
||||||
|
{Words(``, ``, `constant`, `return`), KeywordType, nil},
|
||||||
|
{Words(``, ``, `func`, `loc`, `memref`, `tensor`, `vector`), KeywordType, nil},
|
||||||
|
{`bf16|f16|f32|f64|index`, Keyword, nil},
|
||||||
|
{`i[1-9]\d*`, Keyword, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
4
vendor/github.com/alecthomas/chroma/lexers/p/powershell.go
generated
vendored
4
vendor/github.com/alecthomas/chroma/lexers/p/powershell.go
generated
vendored
@ -22,6 +22,7 @@ var Powershell = internal.Register(MustNewLexer(
|
|||||||
{`^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)`, ByGroups(Comment, LiteralStringDoc, Comment), nil},
|
{`^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)`, ByGroups(Comment, LiteralStringDoc, Comment), nil},
|
||||||
{`#[^\n]*?$`, Comment, nil},
|
{`#[^\n]*?$`, Comment, nil},
|
||||||
{`(<|<)#`, CommentMultiline, Push("multline")},
|
{`(<|<)#`, CommentMultiline, Push("multline")},
|
||||||
|
{`(?i)([A-Z]:)`, Name, nil},
|
||||||
{`@"\n`, LiteralStringHeredoc, Push("heredoc-double")},
|
{`@"\n`, LiteralStringHeredoc, Push("heredoc-double")},
|
||||||
{`@'\n.*?\n'@`, LiteralStringHeredoc, nil},
|
{`@'\n.*?\n'@`, LiteralStringHeredoc, nil},
|
||||||
{"`[\\'\"$@-]", Punctuation, nil},
|
{"`[\\'\"$@-]", Punctuation, nil},
|
||||||
@ -30,7 +31,8 @@ var Powershell = internal.Register(MustNewLexer(
|
|||||||
{`(\$|@@|@)((global|script|private|env):)?\w+`, NameVariable, nil},
|
{`(\$|@@|@)((global|script|private|env):)?\w+`, NameVariable, nil},
|
||||||
{`(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b`, Keyword, nil},
|
{`(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b`, Keyword, nil},
|
||||||
{`-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b`, Operator, nil},
|
{`-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b`, Operator, nil},
|
||||||
{`(write|where|wait|use|update|unregister|undo|trace|test|tee|take|suspend|stop|start|split|sort|skip|show|set|send|select|scroll|resume|restore|restart|resolve|resize|reset|rename|remove|register|receive|read|push|pop|ping|out|new|move|measure|limit|join|invoke|import|group|get|format|foreach|export|expand|exit|enter|enable|disconnect|disable|debug|cxnew|copy|convertto|convertfrom|convert|connect|complete|compare|clear|checkpoint|aggregate|add)-[a-z_]\w*\b`, NameBuiltin, nil},
|
{`(write|where|watch|wait|use|update|unregister|unpublish|unprotect|unlock|uninstall|undo|unblock|trace|test|tee|take|sync|switch|suspend|submit|stop|step|start|split|sort|skip|show|set|send|select|search|scroll|save|revoke|resume|restore|restart|resolve|resize|reset|request|repair|rename|remove|register|redo|receive|read|push|publish|protect|pop|ping|out|optimize|open|new|move|mount|merge|measure|lock|limit|join|invoke|install|initialize|import|hide|group|grant|get|format|foreach|find|export|expand|exit|enter|enable|edit|dismount|disconnect|disable|deny|debug|cxnew|copy|convertto|convertfrom|convert|connect|confirm|compress|complete|compare|close|clear|checkpoint|block|backup|assert|approve|aggregate|add)-[a-z_]\w*\b`, NameBuiltin, nil},
|
||||||
|
{`(ac|asnp|cat|cd|cfs|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|curl|cvpa|dbp|del|diff|dir|dnsn|ebp|echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fhx|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps|gpv|group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md|measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri|rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|wget|where|wjb|write)\s`, NameBuiltin, nil},
|
||||||
{"\\[[a-z_\\[][\\w. `,\\[\\]]*\\]", NameConstant, nil},
|
{"\\[[a-z_\\[][\\w. `,\\[\\]]*\\]", NameConstant, nil},
|
||||||
{`-[a-z_]\w*`, Name, nil},
|
{`-[a-z_]\w*`, Name, nil},
|
||||||
{`\w+`, Name, nil},
|
{`\w+`, Name, nil},
|
||||||
|
200
vendor/github.com/alecthomas/chroma/lexers/s/sml.go
generated
vendored
Normal file
200
vendor/github.com/alecthomas/chroma/lexers/s/sml.go
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
package s
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Standard ML lexer.
|
||||||
|
var StandardML = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "Standard ML",
|
||||||
|
Aliases: []string{"sml"},
|
||||||
|
Filenames: []string{"*.sml", "*.sig", "*.fun"},
|
||||||
|
MimeTypes: []string{"text/x-standardml", "application/x-standardml"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"whitespace": {
|
||||||
|
{`\s+`, Text, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push("comment")},
|
||||||
|
},
|
||||||
|
"delimiters": {
|
||||||
|
{`\(|\[|\{`, Punctuation, Push("main")},
|
||||||
|
{`\)|\]|\}`, Punctuation, Pop(1)},
|
||||||
|
{`\b(let|if|local)\b(?!\')`, KeywordReserved, Push("main", "main")},
|
||||||
|
{`\b(struct|sig|while)\b(?!\')`, KeywordReserved, Push("main")},
|
||||||
|
{`\b(do|else|end|in|then)\b(?!\')`, KeywordReserved, Pop(1)},
|
||||||
|
},
|
||||||
|
"core": {
|
||||||
|
{`(_|\}|\{|\)|;|,|\[|\(|\]|\.\.\.)`, Punctuation, nil},
|
||||||
|
{`#"`, LiteralStringChar, Push("char")},
|
||||||
|
{`"`, LiteralStringDouble, Push("string")},
|
||||||
|
{`~?0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||||
|
{`0wx[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||||
|
{`0w\d+`, LiteralNumberInteger, nil},
|
||||||
|
{`~?\d+\.\d+[eE]~?\d+`, LiteralNumberFloat, nil},
|
||||||
|
{`~?\d+\.\d+`, LiteralNumberFloat, nil},
|
||||||
|
{`~?\d+[eE]~?\d+`, LiteralNumberFloat, nil},
|
||||||
|
{`~?\d+`, LiteralNumberInteger, nil},
|
||||||
|
{`#\s*[1-9][0-9]*`, NameLabel, nil},
|
||||||
|
{`#\s*([a-zA-Z][\w']*)`, NameLabel, nil},
|
||||||
|
{"#\\s+([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameLabel, nil},
|
||||||
|
{`\b(datatype|abstype)\b(?!\')`, KeywordReserved, Push("dname")},
|
||||||
|
{`(?=\b(exception)\b(?!\'))`, Text, Push("ename")},
|
||||||
|
{`\b(functor|include|open|signature|structure)\b(?!\')`, KeywordReserved, Push("sname")},
|
||||||
|
{`\b(type|eqtype)\b(?!\')`, KeywordReserved, Push("tname")},
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`([a-zA-Z][\w']*)(\.)`, NameNamespace, Push("dotted")},
|
||||||
|
{`\b(abstype|and|andalso|as|case|datatype|do|else|end|exception|fn|fun|handle|if|in|infix|infixr|let|local|nonfix|of|op|open|orelse|raise|rec|then|type|val|with|withtype|while|eqtype|functor|include|sharing|sig|signature|struct|structure|where)\b`, KeywordReserved, nil},
|
||||||
|
{`([a-zA-Z][\w']*)`, Name, nil},
|
||||||
|
{`\b(:|\|,=|=>|->|#|:>)\b`, KeywordReserved, nil},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, nil},
|
||||||
|
},
|
||||||
|
"dotted": {
|
||||||
|
{`([a-zA-Z][\w']*)(\.)`, NameNamespace, nil},
|
||||||
|
// ignoring reserved words
|
||||||
|
{`([a-zA-Z][\w']*)`, Name, Pop(1)},
|
||||||
|
// ignoring reserved words
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, Pop(1)},
|
||||||
|
{`\s+`, Error, nil},
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
Default(Push("main")),
|
||||||
|
},
|
||||||
|
"main": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\b(val|and)\b(?!\')`, KeywordReserved, Push("vname")},
|
||||||
|
{`\b(fun)\b(?!\')`, KeywordReserved, Push("#pop", "main-fun", "fname")},
|
||||||
|
Include("delimiters"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"main-fun": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\s`, Text, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push("comment")},
|
||||||
|
{`\b(fun|and)\b(?!\')`, KeywordReserved, Push("fname")},
|
||||||
|
{`\b(val)\b(?!\')`, KeywordReserved, Push("#pop", "main", "vname")},
|
||||||
|
{`\|`, Punctuation, Push("fname")},
|
||||||
|
{`\b(case|handle)\b(?!\')`, KeywordReserved, Push("#pop", "main")},
|
||||||
|
Include("delimiters"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"char": {
|
||||||
|
{`[^"\\]`, LiteralStringChar, nil},
|
||||||
|
{`\\[\\"abtnvfr]`, LiteralStringEscape, nil},
|
||||||
|
{`\\\^[\x40-\x5e]`, LiteralStringEscape, nil},
|
||||||
|
{`\\[0-9]{3}`, LiteralStringEscape, nil},
|
||||||
|
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||||
|
{`\\\s+\\`, LiteralStringInterpol, nil},
|
||||||
|
{`"`, LiteralStringChar, Pop(1)},
|
||||||
|
},
|
||||||
|
"string": {
|
||||||
|
{`[^"\\]`, LiteralStringDouble, nil},
|
||||||
|
{`\\[\\"abtnvfr]`, LiteralStringEscape, nil},
|
||||||
|
{`\\\^[\x40-\x5e]`, LiteralStringEscape, nil},
|
||||||
|
{`\\[0-9]{3}`, LiteralStringEscape, nil},
|
||||||
|
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||||
|
{`\\\s+\\`, LiteralStringInterpol, nil},
|
||||||
|
{`"`, LiteralStringDouble, Pop(1)},
|
||||||
|
},
|
||||||
|
"breakout": {
|
||||||
|
{`(?=\b(where|do|handle|if|sig|op|while|case|as|else|signature|andalso|struct|infixr|functor|in|structure|then|local|rec|end|fun|of|orelse|val|include|fn|with|exception|let|and|infix|sharing|datatype|type|abstype|withtype|eqtype|nonfix|raise|open)\b(?!\'))`, Text, Pop(1)},
|
||||||
|
},
|
||||||
|
"sname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
Include("breakout"),
|
||||||
|
{`([a-zA-Z][\w']*)`, NameNamespace, nil},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"fname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{`([a-zA-Z][\w']*)`, NameFunction, Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameFunction, Pop(1)},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"vname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{"([a-zA-Z][\\w']*)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)},
|
||||||
|
{`([a-zA-Z][\w']*)`, NameVariable, Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameVariable, Pop(1)},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"tname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
Include("breakout"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "typbind")},
|
||||||
|
{`([a-zA-Z][\w']*)`, KeywordType, nil},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil},
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"typbind": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "tname")},
|
||||||
|
Include("breakout"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"dname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
Include("breakout"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{`(=)(\s*)(datatype)`, ByGroups(Punctuation, Text, KeywordReserved), Pop(1)},
|
||||||
|
{"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "datbind", "datcon")},
|
||||||
|
{`([a-zA-Z][\w']*)`, KeywordType, nil},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil},
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"datbind": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "dname")},
|
||||||
|
{`\b(withtype)\b(?!\')`, KeywordReserved, Push("#pop", "tname")},
|
||||||
|
{`\b(of)\b(?!\')`, KeywordReserved, nil},
|
||||||
|
{`(\|)(\s*)([a-zA-Z][\w']*)`, ByGroups(Punctuation, Text, NameClass), nil},
|
||||||
|
{"(\\|)(\\s+)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(Punctuation, Text, NameClass), nil},
|
||||||
|
Include("breakout"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"ename": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`(exception|and)\b(\s+)([a-zA-Z][\w']*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
|
||||||
|
{"(exception|and)\\b(\\s*)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(KeywordReserved, Text, NameClass), nil},
|
||||||
|
{`\b(of)\b(?!\')`, KeywordReserved, nil},
|
||||||
|
Include("breakout"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"datcon": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`([a-zA-Z][\w']*)`, NameClass, Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameClass, Pop(1)},
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"tyvarseq": {
|
||||||
|
{`\s`, Text, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push("comment")},
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`[a-zA-Z][\w']*`, Name, nil},
|
||||||
|
{`,`, Punctuation, nil},
|
||||||
|
{`\)`, Punctuation, Pop(1)},
|
||||||
|
{"[!%&$#+\\-/:<=>?@\\\\~`^|*]+", Name, nil},
|
||||||
|
},
|
||||||
|
"comment": {
|
||||||
|
{`[^(*)]`, CommentMultiline, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push()},
|
||||||
|
{`\*\)`, CommentMultiline, Pop(1)},
|
||||||
|
{`[(*)]`, CommentMultiline, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
42
vendor/github.com/alecthomas/chroma/lexers/t/tablegen.go
generated
vendored
Normal file
42
vendor/github.com/alecthomas/chroma/lexers/t/tablegen.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package t
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TableGen lexer.
|
||||||
|
var Tablegen = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "TableGen",
|
||||||
|
Aliases: []string{"tablegen"},
|
||||||
|
Filenames: []string{"*.td"},
|
||||||
|
MimeTypes: []string{"text/x-tablegen"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
Include("macro"),
|
||||||
|
Include("whitespace"),
|
||||||
|
{`c?"[^"]*?"`, LiteralString, nil},
|
||||||
|
Include("keyword"),
|
||||||
|
{`\$[_a-zA-Z][_\w]*`, NameVariable, nil},
|
||||||
|
{`\d*[_a-zA-Z][_\w]*`, NameVariable, nil},
|
||||||
|
{`\[\{[\w\W]*?\}\]`, LiteralString, nil},
|
||||||
|
{`[+-]?\d+|0x[\da-fA-F]+|0b[01]+`, LiteralNumber, nil},
|
||||||
|
{`[=<>{}\[\]()*.,!:;]`, Punctuation, nil},
|
||||||
|
},
|
||||||
|
"macro": {
|
||||||
|
{`(#include\s+)("[^"]*")`, ByGroups(CommentPreproc, LiteralString), nil},
|
||||||
|
{`^\s*#(ifdef|ifndef)\s+[_\w][_\w\d]*`, CommentPreproc, nil},
|
||||||
|
{`^\s*#define\s+[_\w][_\w\d]*`, CommentPreproc, nil},
|
||||||
|
{`^\s*#endif`, CommentPreproc, nil},
|
||||||
|
},
|
||||||
|
"whitespace": {
|
||||||
|
{`(\n|\s)+`, Text, nil},
|
||||||
|
{`//.*?\n`, Comment, nil},
|
||||||
|
},
|
||||||
|
"keyword": {
|
||||||
|
{Words(``, `\b`, `bit`, `bits`, `class`, `code`, `dag`, `def`, `defm`, `field`, `foreach`, `in`, `int`, `let`, `list`, `multiclass`, `string`), Keyword, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
12
vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
generated
vendored
12
vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
generated
vendored
@ -15,12 +15,15 @@ var YAML = internal.Register(MustNewLexer(
|
|||||||
Rules{
|
Rules{
|
||||||
"root": {
|
"root": {
|
||||||
Include("whitespace"),
|
Include("whitespace"),
|
||||||
{`#.*`, Comment, nil},
|
{`^---`, Text, nil},
|
||||||
|
{`[\n?]?\s*- `, Text, nil},
|
||||||
|
{`#.*$`, Comment, nil},
|
||||||
{`!![^\s]+`, CommentPreproc, nil},
|
{`!![^\s]+`, CommentPreproc, nil},
|
||||||
{`&[^\s]+`, CommentPreproc, nil},
|
{`&[^\s]+`, CommentPreproc, nil},
|
||||||
{`\*[^\s]+`, CommentPreproc, nil},
|
{`\*[^\s]+`, CommentPreproc, nil},
|
||||||
{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
|
{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
|
||||||
{`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
|
{`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
|
||||||
|
Include("key"),
|
||||||
Include("value"),
|
Include("value"),
|
||||||
{`[?:,\[\]]`, Punctuation, nil},
|
{`[?:,\[\]]`, Punctuation, nil},
|
||||||
{`.`, Text, nil},
|
{`.`, Text, nil},
|
||||||
@ -33,8 +36,15 @@ var YAML = internal.Register(MustNewLexer(
|
|||||||
{`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
|
{`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
|
||||||
{`\b[\w]+\b`, Text, nil},
|
{`\b[\w]+\b`, Text, nil},
|
||||||
},
|
},
|
||||||
|
"key": {
|
||||||
|
{`"[^"\n].*": `, Keyword, nil},
|
||||||
|
{`(-)( )([^"\n{]*)(:)( )`, ByGroups(Punctuation, Whitespace, Keyword, Punctuation, Whitespace), nil},
|
||||||
|
{`([^"\n{]*)(:)( )`, ByGroups(Keyword, Punctuation, Whitespace), nil},
|
||||||
|
{`([^"\n{]*)(:)(\n)`, ByGroups(Keyword, Punctuation, Whitespace), nil},
|
||||||
|
},
|
||||||
"whitespace": {
|
"whitespace": {
|
||||||
{`\s+`, Whitespace, nil},
|
{`\s+`, Whitespace, nil},
|
||||||
|
{`\n+`, Whitespace, nil},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
9
vendor/github.com/mattn/go-colorable/.travis.yml
generated
vendored
9
vendor/github.com/mattn/go-colorable/.travis.yml
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
language: go
|
|
||||||
go:
|
|
||||||
- tip
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- go get github.com/mattn/goveralls
|
|
||||||
- go get golang.org/x/tools/cmd/cover
|
|
||||||
script:
|
|
||||||
- $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw
|
|
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
21
vendor/github.com/mattn/go-colorable/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Yasuhiro Matsumoto
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
48
vendor/github.com/mattn/go-colorable/README.md
generated
vendored
48
vendor/github.com/mattn/go-colorable/README.md
generated
vendored
@ -1,48 +0,0 @@
|
|||||||
# go-colorable
|
|
||||||
|
|
||||||
[](http://godoc.org/github.com/mattn/go-colorable)
|
|
||||||
[](https://travis-ci.org/mattn/go-colorable)
|
|
||||||
[](https://coveralls.io/github/mattn/go-colorable?branch=master)
|
|
||||||
[](https://goreportcard.com/report/mattn/go-colorable)
|
|
||||||
|
|
||||||
Colorable writer for windows.
|
|
||||||
|
|
||||||
For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
|
|
||||||
This package is possible to handle escape sequence for ansi color on windows.
|
|
||||||
|
|
||||||
## Too Bad!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## So Good!
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```go
|
|
||||||
logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
|
|
||||||
logrus.SetOutput(colorable.NewColorableStdout())
|
|
||||||
|
|
||||||
logrus.Info("succeeded")
|
|
||||||
logrus.Warn("not correct")
|
|
||||||
logrus.Error("something error")
|
|
||||||
logrus.Fatal("panic")
|
|
||||||
```
|
|
||||||
|
|
||||||
You can compile above code on non-windows OSs.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```
|
|
||||||
$ go get github.com/mattn/go-colorable
|
|
||||||
```
|
|
||||||
|
|
||||||
# License
|
|
||||||
|
|
||||||
MIT
|
|
||||||
|
|
||||||
# Author
|
|
||||||
|
|
||||||
Yasuhiro Matsumoto (a.k.a mattn)
|
|
29
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
29
vendor/github.com/mattn/go-colorable/colorable_appengine.go
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewColorable return new instance of Writer which handle escape sequence.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return os.Stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return os.Stderr
|
|
||||||
}
|
|
30
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
30
vendor/github.com/mattn/go-colorable/colorable_others.go
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// +build !windows
|
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
_ "github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NewColorable return new instance of Writer which handle escape sequence.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return os.Stdout
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return os.Stderr
|
|
||||||
}
|
|
884
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
884
vendor/github.com/mattn/go-colorable/colorable_windows.go
generated
vendored
@ -1,884 +0,0 @@
|
|||||||
// +build windows
|
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
"math"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"github.com/mattn/go-isatty"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
foregroundBlue = 0x1
|
|
||||||
foregroundGreen = 0x2
|
|
||||||
foregroundRed = 0x4
|
|
||||||
foregroundIntensity = 0x8
|
|
||||||
foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity)
|
|
||||||
backgroundBlue = 0x10
|
|
||||||
backgroundGreen = 0x20
|
|
||||||
backgroundRed = 0x40
|
|
||||||
backgroundIntensity = 0x80
|
|
||||||
backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
|
|
||||||
)
|
|
||||||
|
|
||||||
type wchar uint16
|
|
||||||
type short int16
|
|
||||||
type dword uint32
|
|
||||||
type word uint16
|
|
||||||
|
|
||||||
type coord struct {
|
|
||||||
x short
|
|
||||||
y short
|
|
||||||
}
|
|
||||||
|
|
||||||
type smallRect struct {
|
|
||||||
left short
|
|
||||||
top short
|
|
||||||
right short
|
|
||||||
bottom short
|
|
||||||
}
|
|
||||||
|
|
||||||
type consoleScreenBufferInfo struct {
|
|
||||||
size coord
|
|
||||||
cursorPosition coord
|
|
||||||
attributes word
|
|
||||||
window smallRect
|
|
||||||
maximumWindowSize coord
|
|
||||||
}
|
|
||||||
|
|
||||||
type consoleCursorInfo struct {
|
|
||||||
size dword
|
|
||||||
visible int32
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
||||||
procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
|
|
||||||
procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
|
|
||||||
procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
|
|
||||||
procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
|
|
||||||
procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
|
|
||||||
procGetConsoleCursorInfo = kernel32.NewProc("GetConsoleCursorInfo")
|
|
||||||
procSetConsoleCursorInfo = kernel32.NewProc("SetConsoleCursorInfo")
|
|
||||||
procSetConsoleTitle = kernel32.NewProc("SetConsoleTitleW")
|
|
||||||
)
|
|
||||||
|
|
||||||
// Writer provide colorable Writer to the console
|
|
||||||
type Writer struct {
|
|
||||||
out io.Writer
|
|
||||||
handle syscall.Handle
|
|
||||||
oldattr word
|
|
||||||
oldpos coord
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorable return new instance of Writer which handle escape sequence from File.
|
|
||||||
func NewColorable(file *os.File) io.Writer {
|
|
||||||
if file == nil {
|
|
||||||
panic("nil passed instead of *os.File to NewColorable()")
|
|
||||||
}
|
|
||||||
|
|
||||||
if isatty.IsTerminal(file.Fd()) {
|
|
||||||
var csbi consoleScreenBufferInfo
|
|
||||||
handle := syscall.Handle(file.Fd())
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
return &Writer{out: file, handle: handle, oldattr: csbi.attributes, oldpos: coord{0, 0}}
|
|
||||||
}
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
|
|
||||||
func NewColorableStdout() io.Writer {
|
|
||||||
return NewColorable(os.Stdout)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
|
|
||||||
func NewColorableStderr() io.Writer {
|
|
||||||
return NewColorable(os.Stderr)
|
|
||||||
}
|
|
||||||
|
|
||||||
var color256 = map[int]int{
|
|
||||||
0: 0x000000,
|
|
||||||
1: 0x800000,
|
|
||||||
2: 0x008000,
|
|
||||||
3: 0x808000,
|
|
||||||
4: 0x000080,
|
|
||||||
5: 0x800080,
|
|
||||||
6: 0x008080,
|
|
||||||
7: 0xc0c0c0,
|
|
||||||
8: 0x808080,
|
|
||||||
9: 0xff0000,
|
|
||||||
10: 0x00ff00,
|
|
||||||
11: 0xffff00,
|
|
||||||
12: 0x0000ff,
|
|
||||||
13: 0xff00ff,
|
|
||||||
14: 0x00ffff,
|
|
||||||
15: 0xffffff,
|
|
||||||
16: 0x000000,
|
|
||||||
17: 0x00005f,
|
|
||||||
18: 0x000087,
|
|
||||||
19: 0x0000af,
|
|
||||||
20: 0x0000d7,
|
|
||||||
21: 0x0000ff,
|
|
||||||
22: 0x005f00,
|
|
||||||
23: 0x005f5f,
|
|
||||||
24: 0x005f87,
|
|
||||||
25: 0x005faf,
|
|
||||||
26: 0x005fd7,
|
|
||||||
27: 0x005fff,
|
|
||||||
28: 0x008700,
|
|
||||||
29: 0x00875f,
|
|
||||||
30: 0x008787,
|
|
||||||
31: 0x0087af,
|
|
||||||
32: 0x0087d7,
|
|
||||||
33: 0x0087ff,
|
|
||||||
34: 0x00af00,
|
|
||||||
35: 0x00af5f,
|
|
||||||
36: 0x00af87,
|
|
||||||
37: 0x00afaf,
|
|
||||||
38: 0x00afd7,
|
|
||||||
39: 0x00afff,
|
|
||||||
40: 0x00d700,
|
|
||||||
41: 0x00d75f,
|
|
||||||
42: 0x00d787,
|
|
||||||
43: 0x00d7af,
|
|
||||||
44: 0x00d7d7,
|
|
||||||
45: 0x00d7ff,
|
|
||||||
46: 0x00ff00,
|
|
||||||
47: 0x00ff5f,
|
|
||||||
48: 0x00ff87,
|
|
||||||
49: 0x00ffaf,
|
|
||||||
50: 0x00ffd7,
|
|
||||||
51: 0x00ffff,
|
|
||||||
52: 0x5f0000,
|
|
||||||
53: 0x5f005f,
|
|
||||||
54: 0x5f0087,
|
|
||||||
55: 0x5f00af,
|
|
||||||
56: 0x5f00d7,
|
|
||||||
57: 0x5f00ff,
|
|
||||||
58: 0x5f5f00,
|
|
||||||
59: 0x5f5f5f,
|
|
||||||
60: 0x5f5f87,
|
|
||||||
61: 0x5f5faf,
|
|
||||||
62: 0x5f5fd7,
|
|
||||||
63: 0x5f5fff,
|
|
||||||
64: 0x5f8700,
|
|
||||||
65: 0x5f875f,
|
|
||||||
66: 0x5f8787,
|
|
||||||
67: 0x5f87af,
|
|
||||||
68: 0x5f87d7,
|
|
||||||
69: 0x5f87ff,
|
|
||||||
70: 0x5faf00,
|
|
||||||
71: 0x5faf5f,
|
|
||||||
72: 0x5faf87,
|
|
||||||
73: 0x5fafaf,
|
|
||||||
74: 0x5fafd7,
|
|
||||||
75: 0x5fafff,
|
|
||||||
76: 0x5fd700,
|
|
||||||
77: 0x5fd75f,
|
|
||||||
78: 0x5fd787,
|
|
||||||
79: 0x5fd7af,
|
|
||||||
80: 0x5fd7d7,
|
|
||||||
81: 0x5fd7ff,
|
|
||||||
82: 0x5fff00,
|
|
||||||
83: 0x5fff5f,
|
|
||||||
84: 0x5fff87,
|
|
||||||
85: 0x5fffaf,
|
|
||||||
86: 0x5fffd7,
|
|
||||||
87: 0x5fffff,
|
|
||||||
88: 0x870000,
|
|
||||||
89: 0x87005f,
|
|
||||||
90: 0x870087,
|
|
||||||
91: 0x8700af,
|
|
||||||
92: 0x8700d7,
|
|
||||||
93: 0x8700ff,
|
|
||||||
94: 0x875f00,
|
|
||||||
95: 0x875f5f,
|
|
||||||
96: 0x875f87,
|
|
||||||
97: 0x875faf,
|
|
||||||
98: 0x875fd7,
|
|
||||||
99: 0x875fff,
|
|
||||||
100: 0x878700,
|
|
||||||
101: 0x87875f,
|
|
||||||
102: 0x878787,
|
|
||||||
103: 0x8787af,
|
|
||||||
104: 0x8787d7,
|
|
||||||
105: 0x8787ff,
|
|
||||||
106: 0x87af00,
|
|
||||||
107: 0x87af5f,
|
|
||||||
108: 0x87af87,
|
|
||||||
109: 0x87afaf,
|
|
||||||
110: 0x87afd7,
|
|
||||||
111: 0x87afff,
|
|
||||||
112: 0x87d700,
|
|
||||||
113: 0x87d75f,
|
|
||||||
114: 0x87d787,
|
|
||||||
115: 0x87d7af,
|
|
||||||
116: 0x87d7d7,
|
|
||||||
117: 0x87d7ff,
|
|
||||||
118: 0x87ff00,
|
|
||||||
119: 0x87ff5f,
|
|
||||||
120: 0x87ff87,
|
|
||||||
121: 0x87ffaf,
|
|
||||||
122: 0x87ffd7,
|
|
||||||
123: 0x87ffff,
|
|
||||||
124: 0xaf0000,
|
|
||||||
125: 0xaf005f,
|
|
||||||
126: 0xaf0087,
|
|
||||||
127: 0xaf00af,
|
|
||||||
128: 0xaf00d7,
|
|
||||||
129: 0xaf00ff,
|
|
||||||
130: 0xaf5f00,
|
|
||||||
131: 0xaf5f5f,
|
|
||||||
132: 0xaf5f87,
|
|
||||||
133: 0xaf5faf,
|
|
||||||
134: 0xaf5fd7,
|
|
||||||
135: 0xaf5fff,
|
|
||||||
136: 0xaf8700,
|
|
||||||
137: 0xaf875f,
|
|
||||||
138: 0xaf8787,
|
|
||||||
139: 0xaf87af,
|
|
||||||
140: 0xaf87d7,
|
|
||||||
141: 0xaf87ff,
|
|
||||||
142: 0xafaf00,
|
|
||||||
143: 0xafaf5f,
|
|
||||||
144: 0xafaf87,
|
|
||||||
145: 0xafafaf,
|
|
||||||
146: 0xafafd7,
|
|
||||||
147: 0xafafff,
|
|
||||||
148: 0xafd700,
|
|
||||||
149: 0xafd75f,
|
|
||||||
150: 0xafd787,
|
|
||||||
151: 0xafd7af,
|
|
||||||
152: 0xafd7d7,
|
|
||||||
153: 0xafd7ff,
|
|
||||||
154: 0xafff00,
|
|
||||||
155: 0xafff5f,
|
|
||||||
156: 0xafff87,
|
|
||||||
157: 0xafffaf,
|
|
||||||
158: 0xafffd7,
|
|
||||||
159: 0xafffff,
|
|
||||||
160: 0xd70000,
|
|
||||||
161: 0xd7005f,
|
|
||||||
162: 0xd70087,
|
|
||||||
163: 0xd700af,
|
|
||||||
164: 0xd700d7,
|
|
||||||
165: 0xd700ff,
|
|
||||||
166: 0xd75f00,
|
|
||||||
167: 0xd75f5f,
|
|
||||||
168: 0xd75f87,
|
|
||||||
169: 0xd75faf,
|
|
||||||
170: 0xd75fd7,
|
|
||||||
171: 0xd75fff,
|
|
||||||
172: 0xd78700,
|
|
||||||
173: 0xd7875f,
|
|
||||||
174: 0xd78787,
|
|
||||||
175: 0xd787af,
|
|
||||||
176: 0xd787d7,
|
|
||||||
177: 0xd787ff,
|
|
||||||
178: 0xd7af00,
|
|
||||||
179: 0xd7af5f,
|
|
||||||
180: 0xd7af87,
|
|
||||||
181: 0xd7afaf,
|
|
||||||
182: 0xd7afd7,
|
|
||||||
183: 0xd7afff,
|
|
||||||
184: 0xd7d700,
|
|
||||||
185: 0xd7d75f,
|
|
||||||
186: 0xd7d787,
|
|
||||||
187: 0xd7d7af,
|
|
||||||
188: 0xd7d7d7,
|
|
||||||
189: 0xd7d7ff,
|
|
||||||
190: 0xd7ff00,
|
|
||||||
191: 0xd7ff5f,
|
|
||||||
192: 0xd7ff87,
|
|
||||||
193: 0xd7ffaf,
|
|
||||||
194: 0xd7ffd7,
|
|
||||||
195: 0xd7ffff,
|
|
||||||
196: 0xff0000,
|
|
||||||
197: 0xff005f,
|
|
||||||
198: 0xff0087,
|
|
||||||
199: 0xff00af,
|
|
||||||
200: 0xff00d7,
|
|
||||||
201: 0xff00ff,
|
|
||||||
202: 0xff5f00,
|
|
||||||
203: 0xff5f5f,
|
|
||||||
204: 0xff5f87,
|
|
||||||
205: 0xff5faf,
|
|
||||||
206: 0xff5fd7,
|
|
||||||
207: 0xff5fff,
|
|
||||||
208: 0xff8700,
|
|
||||||
209: 0xff875f,
|
|
||||||
210: 0xff8787,
|
|
||||||
211: 0xff87af,
|
|
||||||
212: 0xff87d7,
|
|
||||||
213: 0xff87ff,
|
|
||||||
214: 0xffaf00,
|
|
||||||
215: 0xffaf5f,
|
|
||||||
216: 0xffaf87,
|
|
||||||
217: 0xffafaf,
|
|
||||||
218: 0xffafd7,
|
|
||||||
219: 0xffafff,
|
|
||||||
220: 0xffd700,
|
|
||||||
221: 0xffd75f,
|
|
||||||
222: 0xffd787,
|
|
||||||
223: 0xffd7af,
|
|
||||||
224: 0xffd7d7,
|
|
||||||
225: 0xffd7ff,
|
|
||||||
226: 0xffff00,
|
|
||||||
227: 0xffff5f,
|
|
||||||
228: 0xffff87,
|
|
||||||
229: 0xffffaf,
|
|
||||||
230: 0xffffd7,
|
|
||||||
231: 0xffffff,
|
|
||||||
232: 0x080808,
|
|
||||||
233: 0x121212,
|
|
||||||
234: 0x1c1c1c,
|
|
||||||
235: 0x262626,
|
|
||||||
236: 0x303030,
|
|
||||||
237: 0x3a3a3a,
|
|
||||||
238: 0x444444,
|
|
||||||
239: 0x4e4e4e,
|
|
||||||
240: 0x585858,
|
|
||||||
241: 0x626262,
|
|
||||||
242: 0x6c6c6c,
|
|
||||||
243: 0x767676,
|
|
||||||
244: 0x808080,
|
|
||||||
245: 0x8a8a8a,
|
|
||||||
246: 0x949494,
|
|
||||||
247: 0x9e9e9e,
|
|
||||||
248: 0xa8a8a8,
|
|
||||||
249: 0xb2b2b2,
|
|
||||||
250: 0xbcbcbc,
|
|
||||||
251: 0xc6c6c6,
|
|
||||||
252: 0xd0d0d0,
|
|
||||||
253: 0xdadada,
|
|
||||||
254: 0xe4e4e4,
|
|
||||||
255: 0xeeeeee,
|
|
||||||
}
|
|
||||||
|
|
||||||
// `\033]0;TITLESTR\007`
|
|
||||||
func doTitleSequence(er *bytes.Reader) error {
|
|
||||||
var c byte
|
|
||||||
var err error
|
|
||||||
|
|
||||||
c, err = er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c != '0' && c != '2' {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
c, err = er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c != ';' {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
title := make([]byte, 0, 80)
|
|
||||||
for {
|
|
||||||
c, err = er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c == 0x07 || c == '\n' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
title = append(title, c)
|
|
||||||
}
|
|
||||||
if len(title) > 0 {
|
|
||||||
title8, err := syscall.UTF16PtrFromString(string(title))
|
|
||||||
if err == nil {
|
|
||||||
procSetConsoleTitle.Call(uintptr(unsafe.Pointer(title8)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write write data on console
|
|
||||||
func (w *Writer) Write(data []byte) (n int, err error) {
|
|
||||||
var csbi consoleScreenBufferInfo
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
|
|
||||||
er := bytes.NewReader(data)
|
|
||||||
var bw [1]byte
|
|
||||||
loop:
|
|
||||||
for {
|
|
||||||
c1, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c1 != 0x1b {
|
|
||||||
bw[0] = c1
|
|
||||||
w.out.Write(bw[:])
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c2, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
|
|
||||||
if c2 == ']' {
|
|
||||||
if err := doTitleSequence(er); err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if c2 != 0x5b {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
var m byte
|
|
||||||
for {
|
|
||||||
c, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
|
||||||
m = c
|
|
||||||
break
|
|
||||||
}
|
|
||||||
buf.Write([]byte(string(c)))
|
|
||||||
}
|
|
||||||
|
|
||||||
switch m {
|
|
||||||
case 'A':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.y -= short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'B':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.y += short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'C':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x += short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'D':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x -= short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'E':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x = 0
|
|
||||||
csbi.cursorPosition.y += short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'F':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x = 0
|
|
||||||
csbi.cursorPosition.y -= short(n)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'G':
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
csbi.cursorPosition.x = short(n - 1)
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'H', 'f':
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
token := strings.Split(buf.String(), ";")
|
|
||||||
switch len(token) {
|
|
||||||
case 1:
|
|
||||||
n1, err := strconv.Atoi(token[0])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
csbi.cursorPosition.y = short(n1 - 1)
|
|
||||||
case 2:
|
|
||||||
n1, err := strconv.Atoi(token[0])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
n2, err := strconv.Atoi(token[1])
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
csbi.cursorPosition.x = short(n2 - 1)
|
|
||||||
csbi.cursorPosition.y = short(n1 - 1)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
csbi.cursorPosition.y = 0
|
|
||||||
}
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
|
|
||||||
case 'J':
|
|
||||||
n := 0
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var count, written dword
|
|
||||||
var cursor coord
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
switch n {
|
|
||||||
case 0:
|
|
||||||
cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
|
|
||||||
case 1:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.window.top-csbi.cursorPosition.y)*csbi.size.x)
|
|
||||||
case 2:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
|
|
||||||
}
|
|
||||||
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
case 'K':
|
|
||||||
n := 0
|
|
||||||
if buf.Len() > 0 {
|
|
||||||
n, err = strconv.Atoi(buf.String())
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
var cursor coord
|
|
||||||
var count, written dword
|
|
||||||
switch n {
|
|
||||||
case 0:
|
|
||||||
cursor = coord{x: csbi.cursorPosition.x + 1, y: csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x - 1)
|
|
||||||
case 1:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x - csbi.cursorPosition.x)
|
|
||||||
case 2:
|
|
||||||
cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
|
|
||||||
count = dword(csbi.size.x)
|
|
||||||
}
|
|
||||||
procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
|
|
||||||
case 'm':
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
attr := csbi.attributes
|
|
||||||
cs := buf.String()
|
|
||||||
if cs == "" {
|
|
||||||
procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(w.oldattr))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
token := strings.Split(cs, ";")
|
|
||||||
for i := 0; i < len(token); i++ {
|
|
||||||
ns := token[i]
|
|
||||||
if n, err = strconv.Atoi(ns); err == nil {
|
|
||||||
switch {
|
|
||||||
case n == 0 || n == 100:
|
|
||||||
attr = w.oldattr
|
|
||||||
case 1 <= n && n <= 5:
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
case n == 7:
|
|
||||||
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
|
|
||||||
case n == 22 || n == 25:
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
case n == 27:
|
|
||||||
attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
|
|
||||||
case 30 <= n && n <= 37:
|
|
||||||
attr &= backgroundMask
|
|
||||||
if (n-30)&1 != 0 {
|
|
||||||
attr |= foregroundRed
|
|
||||||
}
|
|
||||||
if (n-30)&2 != 0 {
|
|
||||||
attr |= foregroundGreen
|
|
||||||
}
|
|
||||||
if (n-30)&4 != 0 {
|
|
||||||
attr |= foregroundBlue
|
|
||||||
}
|
|
||||||
case n == 38: // set foreground color.
|
|
||||||
if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") {
|
|
||||||
if n256, err := strconv.Atoi(token[i+2]); err == nil {
|
|
||||||
if n256foreAttr == nil {
|
|
||||||
n256setup()
|
|
||||||
}
|
|
||||||
attr &= backgroundMask
|
|
||||||
attr |= n256foreAttr[n256]
|
|
||||||
i += 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attr = attr & (w.oldattr & backgroundMask)
|
|
||||||
}
|
|
||||||
case n == 39: // reset foreground color.
|
|
||||||
attr &= backgroundMask
|
|
||||||
attr |= w.oldattr & foregroundMask
|
|
||||||
case 40 <= n && n <= 47:
|
|
||||||
attr &= foregroundMask
|
|
||||||
if (n-40)&1 != 0 {
|
|
||||||
attr |= backgroundRed
|
|
||||||
}
|
|
||||||
if (n-40)&2 != 0 {
|
|
||||||
attr |= backgroundGreen
|
|
||||||
}
|
|
||||||
if (n-40)&4 != 0 {
|
|
||||||
attr |= backgroundBlue
|
|
||||||
}
|
|
||||||
case n == 48: // set background color.
|
|
||||||
if i < len(token)-2 && token[i+1] == "5" {
|
|
||||||
if n256, err := strconv.Atoi(token[i+2]); err == nil {
|
|
||||||
if n256backAttr == nil {
|
|
||||||
n256setup()
|
|
||||||
}
|
|
||||||
attr &= foregroundMask
|
|
||||||
attr |= n256backAttr[n256]
|
|
||||||
i += 2
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attr = attr & (w.oldattr & foregroundMask)
|
|
||||||
}
|
|
||||||
case n == 49: // reset foreground color.
|
|
||||||
attr &= foregroundMask
|
|
||||||
attr |= w.oldattr & backgroundMask
|
|
||||||
case 90 <= n && n <= 97:
|
|
||||||
attr = (attr & backgroundMask)
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
if (n-90)&1 != 0 {
|
|
||||||
attr |= foregroundRed
|
|
||||||
}
|
|
||||||
if (n-90)&2 != 0 {
|
|
||||||
attr |= foregroundGreen
|
|
||||||
}
|
|
||||||
if (n-90)&4 != 0 {
|
|
||||||
attr |= foregroundBlue
|
|
||||||
}
|
|
||||||
case 100 <= n && n <= 107:
|
|
||||||
attr = (attr & foregroundMask)
|
|
||||||
attr |= backgroundIntensity
|
|
||||||
if (n-100)&1 != 0 {
|
|
||||||
attr |= backgroundRed
|
|
||||||
}
|
|
||||||
if (n-100)&2 != 0 {
|
|
||||||
attr |= backgroundGreen
|
|
||||||
}
|
|
||||||
if (n-100)&4 != 0 {
|
|
||||||
attr |= backgroundBlue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(attr))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 'h':
|
|
||||||
var ci consoleCursorInfo
|
|
||||||
cs := buf.String()
|
|
||||||
if cs == "5>" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 0
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
} else if cs == "?25" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 1
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
}
|
|
||||||
case 'l':
|
|
||||||
var ci consoleCursorInfo
|
|
||||||
cs := buf.String()
|
|
||||||
if cs == "5>" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 1
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
} else if cs == "?25" {
|
|
||||||
procGetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
ci.visible = 0
|
|
||||||
procSetConsoleCursorInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&ci)))
|
|
||||||
}
|
|
||||||
case 's':
|
|
||||||
procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
|
|
||||||
w.oldpos = csbi.cursorPosition
|
|
||||||
case 'u':
|
|
||||||
procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&w.oldpos)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(data), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type consoleColor struct {
|
|
||||||
rgb int
|
|
||||||
red bool
|
|
||||||
green bool
|
|
||||||
blue bool
|
|
||||||
intensity bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c consoleColor) foregroundAttr() (attr word) {
|
|
||||||
if c.red {
|
|
||||||
attr |= foregroundRed
|
|
||||||
}
|
|
||||||
if c.green {
|
|
||||||
attr |= foregroundGreen
|
|
||||||
}
|
|
||||||
if c.blue {
|
|
||||||
attr |= foregroundBlue
|
|
||||||
}
|
|
||||||
if c.intensity {
|
|
||||||
attr |= foregroundIntensity
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c consoleColor) backgroundAttr() (attr word) {
|
|
||||||
if c.red {
|
|
||||||
attr |= backgroundRed
|
|
||||||
}
|
|
||||||
if c.green {
|
|
||||||
attr |= backgroundGreen
|
|
||||||
}
|
|
||||||
if c.blue {
|
|
||||||
attr |= backgroundBlue
|
|
||||||
}
|
|
||||||
if c.intensity {
|
|
||||||
attr |= backgroundIntensity
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var color16 = []consoleColor{
|
|
||||||
{0x000000, false, false, false, false},
|
|
||||||
{0x000080, false, false, true, false},
|
|
||||||
{0x008000, false, true, false, false},
|
|
||||||
{0x008080, false, true, true, false},
|
|
||||||
{0x800000, true, false, false, false},
|
|
||||||
{0x800080, true, false, true, false},
|
|
||||||
{0x808000, true, true, false, false},
|
|
||||||
{0xc0c0c0, true, true, true, false},
|
|
||||||
{0x808080, false, false, false, true},
|
|
||||||
{0x0000ff, false, false, true, true},
|
|
||||||
{0x00ff00, false, true, false, true},
|
|
||||||
{0x00ffff, false, true, true, true},
|
|
||||||
{0xff0000, true, false, false, true},
|
|
||||||
{0xff00ff, true, false, true, true},
|
|
||||||
{0xffff00, true, true, false, true},
|
|
||||||
{0xffffff, true, true, true, true},
|
|
||||||
}
|
|
||||||
|
|
||||||
type hsv struct {
|
|
||||||
h, s, v float32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a hsv) dist(b hsv) float32 {
|
|
||||||
dh := a.h - b.h
|
|
||||||
switch {
|
|
||||||
case dh > 0.5:
|
|
||||||
dh = 1 - dh
|
|
||||||
case dh < -0.5:
|
|
||||||
dh = -1 - dh
|
|
||||||
}
|
|
||||||
ds := a.s - b.s
|
|
||||||
dv := a.v - b.v
|
|
||||||
return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func toHSV(rgb int) hsv {
|
|
||||||
r, g, b := float32((rgb&0xFF0000)>>16)/256.0,
|
|
||||||
float32((rgb&0x00FF00)>>8)/256.0,
|
|
||||||
float32(rgb&0x0000FF)/256.0
|
|
||||||
min, max := minmax3f(r, g, b)
|
|
||||||
h := max - min
|
|
||||||
if h > 0 {
|
|
||||||
if max == r {
|
|
||||||
h = (g - b) / h
|
|
||||||
if h < 0 {
|
|
||||||
h += 6
|
|
||||||
}
|
|
||||||
} else if max == g {
|
|
||||||
h = 2 + (b-r)/h
|
|
||||||
} else {
|
|
||||||
h = 4 + (r-g)/h
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h /= 6.0
|
|
||||||
s := max - min
|
|
||||||
if max != 0 {
|
|
||||||
s /= max
|
|
||||||
}
|
|
||||||
v := max
|
|
||||||
return hsv{h: h, s: s, v: v}
|
|
||||||
}
|
|
||||||
|
|
||||||
type hsvTable []hsv
|
|
||||||
|
|
||||||
func toHSVTable(rgbTable []consoleColor) hsvTable {
|
|
||||||
t := make(hsvTable, len(rgbTable))
|
|
||||||
for i, c := range rgbTable {
|
|
||||||
t[i] = toHSV(c.rgb)
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t hsvTable) find(rgb int) consoleColor {
|
|
||||||
hsv := toHSV(rgb)
|
|
||||||
n := 7
|
|
||||||
l := float32(5.0)
|
|
||||||
for i, p := range t {
|
|
||||||
d := hsv.dist(p)
|
|
||||||
if d < l {
|
|
||||||
l, n = d, i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color16[n]
|
|
||||||
}
|
|
||||||
|
|
||||||
func minmax3f(a, b, c float32) (min, max float32) {
|
|
||||||
if a < b {
|
|
||||||
if b < c {
|
|
||||||
return a, c
|
|
||||||
} else if a < c {
|
|
||||||
return a, b
|
|
||||||
} else {
|
|
||||||
return c, b
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if a < c {
|
|
||||||
return b, c
|
|
||||||
} else if b < c {
|
|
||||||
return b, a
|
|
||||||
} else {
|
|
||||||
return c, a
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var n256foreAttr []word
|
|
||||||
var n256backAttr []word
|
|
||||||
|
|
||||||
func n256setup() {
|
|
||||||
n256foreAttr = make([]word, 256)
|
|
||||||
n256backAttr = make([]word, 256)
|
|
||||||
t := toHSVTable(color16)
|
|
||||||
for i, rgb := range color256 {
|
|
||||||
c := t.find(rgb)
|
|
||||||
n256foreAttr[i] = c.foregroundAttr()
|
|
||||||
n256backAttr[i] = c.backgroundAttr()
|
|
||||||
}
|
|
||||||
}
|
|
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
55
vendor/github.com/mattn/go-colorable/noncolorable.go
generated
vendored
@ -1,55 +0,0 @@
|
|||||||
package colorable
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NonColorable hold writer but remove escape sequence.
|
|
||||||
type NonColorable struct {
|
|
||||||
out io.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewNonColorable return new instance of Writer which remove escape sequence from Writer.
|
|
||||||
func NewNonColorable(w io.Writer) io.Writer {
|
|
||||||
return &NonColorable{out: w}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write write data on console
|
|
||||||
func (w *NonColorable) Write(data []byte) (n int, err error) {
|
|
||||||
er := bytes.NewReader(data)
|
|
||||||
var bw [1]byte
|
|
||||||
loop:
|
|
||||||
for {
|
|
||||||
c1, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c1 != 0x1b {
|
|
||||||
bw[0] = c1
|
|
||||||
w.out.Write(bw[:])
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
c2, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if c2 != 0x5b {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
|
||||||
for {
|
|
||||||
c, err := er.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
buf.Write([]byte(string(c)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len(data), nil
|
|
||||||
}
|
|
15
vendor/github.com/mattn/go-isatty/.travis.yml
generated
vendored
15
vendor/github.com/mattn/go-isatty/.travis.yml
generated
vendored
@ -1,13 +1,14 @@
|
|||||||
language: go
|
language: go
|
||||||
|
sudo: false
|
||||||
go:
|
go:
|
||||||
|
- 1.13.x
|
||||||
- tip
|
- tip
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- go get github.com/mattn/goveralls
|
- go get -t -v ./...
|
||||||
- go get golang.org/x/tools/cmd/cover
|
|
||||||
script:
|
script:
|
||||||
- $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5
|
- ./go.test.sh
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
2
vendor/github.com/mattn/go-isatty/README.md
generated
vendored
2
vendor/github.com/mattn/go-isatty/README.md
generated
vendored
@ -1,7 +1,7 @@
|
|||||||
# go-isatty
|
# go-isatty
|
||||||
|
|
||||||
[](http://godoc.org/github.com/mattn/go-isatty)
|
[](http://godoc.org/github.com/mattn/go-isatty)
|
||||||
[](https://travis-ci.org/mattn/go-isatty)
|
[](https://codecov.io/gh/mattn/go-isatty)
|
||||||
[](https://coveralls.io/github/mattn/go-isatty?branch=master)
|
[](https://coveralls.io/github/mattn/go-isatty?branch=master)
|
||||||
[](https://goreportcard.com/report/mattn/go-isatty)
|
[](https://goreportcard.com/report/mattn/go-isatty)
|
||||||
|
|
||||||
|
2
vendor/github.com/mattn/go-isatty/go.mod
generated
vendored
2
vendor/github.com/mattn/go-isatty/go.mod
generated
vendored
@ -2,4 +2,4 @@ module github.com/mattn/go-isatty
|
|||||||
|
|
||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
|
require golang.org/x/sys v0.0.0-20200116001909-b77594299b42
|
||||||
|
4
vendor/github.com/mattn/go-isatty/go.sum
generated
vendored
4
vendor/github.com/mattn/go-isatty/go.sum
generated
vendored
@ -1,2 +1,2 @@
|
|||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
12
vendor/github.com/mattn/go-isatty/go.test.sh
generated
vendored
Normal file
12
vendor/github.com/mattn/go-isatty/go.test.sh
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
echo "" > coverage.txt
|
||||||
|
|
||||||
|
for d in $(go list ./... | grep -v vendor); do
|
||||||
|
go test -race -coverprofile=profile.out -covermode=atomic "$d"
|
||||||
|
if [ -f profile.out ]; then
|
||||||
|
cat profile.out >> coverage.txt
|
||||||
|
rm profile.out
|
||||||
|
fi
|
||||||
|
done
|
23
vendor/github.com/mattn/go-isatty/isatty_android.go
generated
vendored
23
vendor/github.com/mattn/go-isatty/isatty_android.go
generated
vendored
@ -1,23 +0,0 @@
|
|||||||
// +build android
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const ioctlReadTermios = syscall.TCGETS
|
|
||||||
|
|
||||||
// IsTerminal return true if the file descriptor is terminal.
|
|
||||||
func IsTerminal(fd uintptr) bool {
|
|
||||||
var termios syscall.Termios
|
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
|
||||||
return err == 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
|
||||||
// terminal. This is also always false on this environment.
|
|
||||||
func IsCygwinTerminal(fd uintptr) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
12
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
12
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
@ -3,18 +3,12 @@
|
|||||||
|
|
||||||
package isatty
|
package isatty
|
||||||
|
|
||||||
import (
|
import "golang.org/x/sys/unix"
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const ioctlReadTermios = syscall.TIOCGETA
|
|
||||||
|
|
||||||
// IsTerminal return true if the file descriptor is terminal.
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
func IsTerminal(fd uintptr) bool {
|
func IsTerminal(fd uintptr) bool {
|
||||||
var termios syscall.Termios
|
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
return err == nil
|
||||||
return err == 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
1
vendor/github.com/mattn/go-isatty/isatty_tcgets.go
generated
vendored
1
vendor/github.com/mattn/go-isatty/isatty_tcgets.go
generated
vendored
@ -1,6 +1,5 @@
|
|||||||
// +build linux aix
|
// +build linux aix
|
||||||
// +build !appengine
|
// +build !appengine
|
||||||
// +build !android
|
|
||||||
|
|
||||||
package isatty
|
package isatty
|
||||||
|
|
||||||
|
8
vendor/github.com/mattn/go-isatty/renovate.json
generated
vendored
Normal file
8
vendor/github.com/mattn/go-isatty/renovate.json
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
],
|
||||||
|
"postUpdateOptions": [
|
||||||
|
"gomodTidy"
|
||||||
|
]
|
||||||
|
}
|
1
vendor/github.com/mgutz/ansi/.gitignore
generated
vendored
1
vendor/github.com/mgutz/ansi/.gitignore
generated
vendored
@ -1 +0,0 @@
|
|||||||
*.test
|
|
9
vendor/github.com/mgutz/ansi/LICENSE
generated
vendored
9
vendor/github.com/mgutz/ansi/LICENSE
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
Copyright (c) 2013 Mario L. Gutierrez
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
121
vendor/github.com/mgutz/ansi/README.md
generated
vendored
121
vendor/github.com/mgutz/ansi/README.md
generated
vendored
@ -1,121 +0,0 @@
|
|||||||
# ansi
|
|
||||||
|
|
||||||
Package ansi is a small, fast library to create ANSI colored strings and codes.
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
Get it
|
|
||||||
|
|
||||||
```sh
|
|
||||||
go get -u github.com/mgutz/ansi
|
|
||||||
```
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```go
|
|
||||||
import "github.com/mgutz/ansi"
|
|
||||||
|
|
||||||
// colorize a string, SLOW
|
|
||||||
msg := ansi.Color("foo", "red+b:white")
|
|
||||||
|
|
||||||
// create a FAST closure function to avoid computation of ANSI code
|
|
||||||
phosphorize := ansi.ColorFunc("green+h:black")
|
|
||||||
msg = phosphorize("Bring back the 80s!")
|
|
||||||
msg2 := phospohorize("Look, I'm a CRT!")
|
|
||||||
|
|
||||||
// cache escape codes and build strings manually
|
|
||||||
lime := ansi.ColorCode("green+h:black")
|
|
||||||
reset := ansi.ColorCode("reset")
|
|
||||||
|
|
||||||
fmt.Println(lime, "Bring back the 80s!", reset)
|
|
||||||
```
|
|
||||||
|
|
||||||
Other examples
|
|
||||||
|
|
||||||
```go
|
|
||||||
Color(s, "red") // red
|
|
||||||
Color(s, "red+b") // red bold
|
|
||||||
Color(s, "red+B") // red blinking
|
|
||||||
Color(s, "red+u") // red underline
|
|
||||||
Color(s, "red+bh") // red bold bright
|
|
||||||
Color(s, "red:white") // red on white
|
|
||||||
Color(s, "red+b:white+h") // red bold on white bright
|
|
||||||
Color(s, "red+B:white+h") // red blink on white bright
|
|
||||||
Color(s, "off") // turn off ansi codes
|
|
||||||
```
|
|
||||||
|
|
||||||
To view color combinations, from project directory in terminal.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
go test
|
|
||||||
```
|
|
||||||
|
|
||||||
## Style format
|
|
||||||
|
|
||||||
```go
|
|
||||||
"foregroundColor+attributes:backgroundColor+attributes"
|
|
||||||
```
|
|
||||||
|
|
||||||
Colors
|
|
||||||
|
|
||||||
* black
|
|
||||||
* red
|
|
||||||
* green
|
|
||||||
* yellow
|
|
||||||
* blue
|
|
||||||
* magenta
|
|
||||||
* cyan
|
|
||||||
* white
|
|
||||||
* 0...255 (256 colors)
|
|
||||||
|
|
||||||
Foreground Attributes
|
|
||||||
|
|
||||||
* B = Blink
|
|
||||||
* b = bold
|
|
||||||
* h = high intensity (bright)
|
|
||||||
* i = inverse
|
|
||||||
* s = strikethrough
|
|
||||||
* u = underline
|
|
||||||
|
|
||||||
Background Attributes
|
|
||||||
|
|
||||||
* h = high intensity (bright)
|
|
||||||
|
|
||||||
## Constants
|
|
||||||
|
|
||||||
* ansi.Reset
|
|
||||||
* ansi.DefaultBG
|
|
||||||
* ansi.DefaultFG
|
|
||||||
* ansi.Black
|
|
||||||
* ansi.Red
|
|
||||||
* ansi.Green
|
|
||||||
* ansi.Yellow
|
|
||||||
* ansi.Blue
|
|
||||||
* ansi.Magenta
|
|
||||||
* ansi.Cyan
|
|
||||||
* ansi.White
|
|
||||||
* ansi.LightBlack
|
|
||||||
* ansi.LightRed
|
|
||||||
* ansi.LightGreen
|
|
||||||
* ansi.LightYellow
|
|
||||||
* ansi.LightBlue
|
|
||||||
* ansi.LightMagenta
|
|
||||||
* ansi.LightCyan
|
|
||||||
* ansi.LightWhite
|
|
||||||
|
|
||||||
## References
|
|
||||||
|
|
||||||
Wikipedia ANSI escape codes [Colors](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
|
|
||||||
|
|
||||||
General [tips and formatting](http://misc.flogisoft.com/bash/tip_colors_and_formatting)
|
|
||||||
|
|
||||||
What about support on Windows? Use [colorable by mattn](https://github.com/mattn/go-colorable).
|
|
||||||
Ansi and colorable are used by [logxi](https://github.com/mgutz/logxi) to support logging in
|
|
||||||
color on Windows.
|
|
||||||
|
|
||||||
## MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2013 Mario Gutierrez mario@mgutz.com
|
|
||||||
|
|
||||||
See the file LICENSE for copying permission.
|
|
||||||
|
|
285
vendor/github.com/mgutz/ansi/ansi.go
generated
vendored
285
vendor/github.com/mgutz/ansi/ansi.go
generated
vendored
@ -1,285 +0,0 @@
|
|||||||
package ansi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
black = iota
|
|
||||||
red
|
|
||||||
green
|
|
||||||
yellow
|
|
||||||
blue
|
|
||||||
magenta
|
|
||||||
cyan
|
|
||||||
white
|
|
||||||
defaultt = 9
|
|
||||||
|
|
||||||
normalIntensityFG = 30
|
|
||||||
highIntensityFG = 90
|
|
||||||
normalIntensityBG = 40
|
|
||||||
highIntensityBG = 100
|
|
||||||
|
|
||||||
start = "\033["
|
|
||||||
bold = "1;"
|
|
||||||
blink = "5;"
|
|
||||||
underline = "4;"
|
|
||||||
inverse = "7;"
|
|
||||||
strikethrough = "9;"
|
|
||||||
|
|
||||||
// Reset is the ANSI reset escape sequence
|
|
||||||
Reset = "\033[0m"
|
|
||||||
// DefaultBG is the default background
|
|
||||||
DefaultBG = "\033[49m"
|
|
||||||
// DefaultFG is the default foreground
|
|
||||||
DefaultFG = "\033[39m"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Black FG
|
|
||||||
var Black string
|
|
||||||
|
|
||||||
// Red FG
|
|
||||||
var Red string
|
|
||||||
|
|
||||||
// Green FG
|
|
||||||
var Green string
|
|
||||||
|
|
||||||
// Yellow FG
|
|
||||||
var Yellow string
|
|
||||||
|
|
||||||
// Blue FG
|
|
||||||
var Blue string
|
|
||||||
|
|
||||||
// Magenta FG
|
|
||||||
var Magenta string
|
|
||||||
|
|
||||||
// Cyan FG
|
|
||||||
var Cyan string
|
|
||||||
|
|
||||||
// White FG
|
|
||||||
var White string
|
|
||||||
|
|
||||||
// LightBlack FG
|
|
||||||
var LightBlack string
|
|
||||||
|
|
||||||
// LightRed FG
|
|
||||||
var LightRed string
|
|
||||||
|
|
||||||
// LightGreen FG
|
|
||||||
var LightGreen string
|
|
||||||
|
|
||||||
// LightYellow FG
|
|
||||||
var LightYellow string
|
|
||||||
|
|
||||||
// LightBlue FG
|
|
||||||
var LightBlue string
|
|
||||||
|
|
||||||
// LightMagenta FG
|
|
||||||
var LightMagenta string
|
|
||||||
|
|
||||||
// LightCyan FG
|
|
||||||
var LightCyan string
|
|
||||||
|
|
||||||
// LightWhite FG
|
|
||||||
var LightWhite string
|
|
||||||
|
|
||||||
var (
|
|
||||||
plain = false
|
|
||||||
// Colors maps common color names to their ANSI color code.
|
|
||||||
Colors = map[string]int{
|
|
||||||
"black": black,
|
|
||||||
"red": red,
|
|
||||||
"green": green,
|
|
||||||
"yellow": yellow,
|
|
||||||
"blue": blue,
|
|
||||||
"magenta": magenta,
|
|
||||||
"cyan": cyan,
|
|
||||||
"white": white,
|
|
||||||
"default": defaultt,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
for i := 0; i < 256; i++ {
|
|
||||||
Colors[strconv.Itoa(i)] = i
|
|
||||||
}
|
|
||||||
|
|
||||||
Black = ColorCode("black")
|
|
||||||
Red = ColorCode("red")
|
|
||||||
Green = ColorCode("green")
|
|
||||||
Yellow = ColorCode("yellow")
|
|
||||||
Blue = ColorCode("blue")
|
|
||||||
Magenta = ColorCode("magenta")
|
|
||||||
Cyan = ColorCode("cyan")
|
|
||||||
White = ColorCode("white")
|
|
||||||
LightBlack = ColorCode("black+h")
|
|
||||||
LightRed = ColorCode("red+h")
|
|
||||||
LightGreen = ColorCode("green+h")
|
|
||||||
LightYellow = ColorCode("yellow+h")
|
|
||||||
LightBlue = ColorCode("blue+h")
|
|
||||||
LightMagenta = ColorCode("magenta+h")
|
|
||||||
LightCyan = ColorCode("cyan+h")
|
|
||||||
LightWhite = ColorCode("white+h")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ColorCode returns the ANSI color color code for style.
|
|
||||||
func ColorCode(style string) string {
|
|
||||||
return colorCode(style).String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets the ANSI color code for a style.
|
|
||||||
func colorCode(style string) *bytes.Buffer {
|
|
||||||
buf := bytes.NewBufferString("")
|
|
||||||
if plain || style == "" {
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
if style == "reset" {
|
|
||||||
buf.WriteString(Reset)
|
|
||||||
return buf
|
|
||||||
} else if style == "off" {
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
foregroundBackground := strings.Split(style, ":")
|
|
||||||
foreground := strings.Split(foregroundBackground[0], "+")
|
|
||||||
fgKey := foreground[0]
|
|
||||||
fg := Colors[fgKey]
|
|
||||||
fgStyle := ""
|
|
||||||
if len(foreground) > 1 {
|
|
||||||
fgStyle = foreground[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
bg, bgStyle := "", ""
|
|
||||||
|
|
||||||
if len(foregroundBackground) > 1 {
|
|
||||||
background := strings.Split(foregroundBackground[1], "+")
|
|
||||||
bg = background[0]
|
|
||||||
if len(background) > 1 {
|
|
||||||
bgStyle = background[1]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.WriteString(start)
|
|
||||||
base := normalIntensityFG
|
|
||||||
if len(fgStyle) > 0 {
|
|
||||||
if strings.Contains(fgStyle, "b") {
|
|
||||||
buf.WriteString(bold)
|
|
||||||
}
|
|
||||||
if strings.Contains(fgStyle, "B") {
|
|
||||||
buf.WriteString(blink)
|
|
||||||
}
|
|
||||||
if strings.Contains(fgStyle, "u") {
|
|
||||||
buf.WriteString(underline)
|
|
||||||
}
|
|
||||||
if strings.Contains(fgStyle, "i") {
|
|
||||||
buf.WriteString(inverse)
|
|
||||||
}
|
|
||||||
if strings.Contains(fgStyle, "s") {
|
|
||||||
buf.WriteString(strikethrough)
|
|
||||||
}
|
|
||||||
if strings.Contains(fgStyle, "h") {
|
|
||||||
base = highIntensityFG
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if 256-color
|
|
||||||
n, err := strconv.Atoi(fgKey)
|
|
||||||
if err == nil {
|
|
||||||
fmt.Fprintf(buf, "38;5;%d;", n)
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(buf, "%d;", base+fg)
|
|
||||||
}
|
|
||||||
|
|
||||||
base = normalIntensityBG
|
|
||||||
if len(bg) > 0 {
|
|
||||||
if strings.Contains(bgStyle, "h") {
|
|
||||||
base = highIntensityBG
|
|
||||||
}
|
|
||||||
// if 256-color
|
|
||||||
n, err := strconv.Atoi(bg)
|
|
||||||
if err == nil {
|
|
||||||
fmt.Fprintf(buf, "48;5;%d;", n)
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(buf, "%d;", base+Colors[bg])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove last ";"
|
|
||||||
buf.Truncate(buf.Len() - 1)
|
|
||||||
buf.WriteRune('m')
|
|
||||||
return buf
|
|
||||||
}
|
|
||||||
|
|
||||||
// Color colors a string based on the ANSI color code for style.
|
|
||||||
func Color(s, style string) string {
|
|
||||||
if plain || len(style) < 1 {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
buf := colorCode(style)
|
|
||||||
buf.WriteString(s)
|
|
||||||
buf.WriteString(Reset)
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ColorFunc creates a closure to avoid computation ANSI color code.
|
|
||||||
func ColorFunc(style string) func(string) string {
|
|
||||||
if style == "" {
|
|
||||||
return func(s string) string {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
}
|
|
||||||
color := ColorCode(style)
|
|
||||||
return func(s string) string {
|
|
||||||
if plain || s == "" {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
buf := bytes.NewBufferString(color)
|
|
||||||
buf.WriteString(s)
|
|
||||||
buf.WriteString(Reset)
|
|
||||||
result := buf.String()
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DisableColors disables ANSI color codes. The default is false (colors are on).
|
|
||||||
func DisableColors(disable bool) {
|
|
||||||
plain = disable
|
|
||||||
if plain {
|
|
||||||
Black = ""
|
|
||||||
Red = ""
|
|
||||||
Green = ""
|
|
||||||
Yellow = ""
|
|
||||||
Blue = ""
|
|
||||||
Magenta = ""
|
|
||||||
Cyan = ""
|
|
||||||
White = ""
|
|
||||||
LightBlack = ""
|
|
||||||
LightRed = ""
|
|
||||||
LightGreen = ""
|
|
||||||
LightYellow = ""
|
|
||||||
LightBlue = ""
|
|
||||||
LightMagenta = ""
|
|
||||||
LightCyan = ""
|
|
||||||
LightWhite = ""
|
|
||||||
} else {
|
|
||||||
Black = ColorCode("black")
|
|
||||||
Red = ColorCode("red")
|
|
||||||
Green = ColorCode("green")
|
|
||||||
Yellow = ColorCode("yellow")
|
|
||||||
Blue = ColorCode("blue")
|
|
||||||
Magenta = ColorCode("magenta")
|
|
||||||
Cyan = ColorCode("cyan")
|
|
||||||
White = ColorCode("white")
|
|
||||||
LightBlack = ColorCode("black+h")
|
|
||||||
LightRed = ColorCode("red+h")
|
|
||||||
LightGreen = ColorCode("green+h")
|
|
||||||
LightYellow = ColorCode("yellow+h")
|
|
||||||
LightBlue = ColorCode("blue+h")
|
|
||||||
LightMagenta = ColorCode("magenta+h")
|
|
||||||
LightCyan = ColorCode("cyan+h")
|
|
||||||
LightWhite = ColorCode("white+h")
|
|
||||||
}
|
|
||||||
}
|
|
65
vendor/github.com/mgutz/ansi/doc.go
generated
vendored
65
vendor/github.com/mgutz/ansi/doc.go
generated
vendored
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
Package ansi is a small, fast library to create ANSI colored strings and codes.
|
|
||||||
|
|
||||||
Installation
|
|
||||||
|
|
||||||
# this installs the color viewer and the package
|
|
||||||
go get -u github.com/mgutz/ansi/cmd/ansi-mgutz
|
|
||||||
|
|
||||||
Example
|
|
||||||
|
|
||||||
// colorize a string, SLOW
|
|
||||||
msg := ansi.Color("foo", "red+b:white")
|
|
||||||
|
|
||||||
// create a closure to avoid recalculating ANSI code compilation
|
|
||||||
phosphorize := ansi.ColorFunc("green+h:black")
|
|
||||||
msg = phosphorize("Bring back the 80s!")
|
|
||||||
msg2 := phospohorize("Look, I'm a CRT!")
|
|
||||||
|
|
||||||
// cache escape codes and build strings manually
|
|
||||||
lime := ansi.ColorCode("green+h:black")
|
|
||||||
reset := ansi.ColorCode("reset")
|
|
||||||
|
|
||||||
fmt.Println(lime, "Bring back the 80s!", reset)
|
|
||||||
|
|
||||||
Other examples
|
|
||||||
|
|
||||||
Color(s, "red") // red
|
|
||||||
Color(s, "red+b") // red bold
|
|
||||||
Color(s, "red+B") // red blinking
|
|
||||||
Color(s, "red+u") // red underline
|
|
||||||
Color(s, "red+bh") // red bold bright
|
|
||||||
Color(s, "red:white") // red on white
|
|
||||||
Color(s, "red+b:white+h") // red bold on white bright
|
|
||||||
Color(s, "red+B:white+h") // red blink on white bright
|
|
||||||
|
|
||||||
To view color combinations, from terminal
|
|
||||||
|
|
||||||
ansi-mgutz
|
|
||||||
|
|
||||||
Style format
|
|
||||||
|
|
||||||
"foregroundColor+attributes:backgroundColor+attributes"
|
|
||||||
|
|
||||||
Colors
|
|
||||||
|
|
||||||
black
|
|
||||||
red
|
|
||||||
green
|
|
||||||
yellow
|
|
||||||
blue
|
|
||||||
magenta
|
|
||||||
cyan
|
|
||||||
white
|
|
||||||
|
|
||||||
Attributes
|
|
||||||
|
|
||||||
b = bold foreground
|
|
||||||
B = Blink foreground
|
|
||||||
u = underline foreground
|
|
||||||
h = high intensity (bright) foreground, background
|
|
||||||
i = inverse
|
|
||||||
|
|
||||||
Wikipedia ANSI escape codes [Colors](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors)
|
|
||||||
*/
|
|
||||||
package ansi
|
|
57
vendor/github.com/mgutz/ansi/print.go
generated
vendored
57
vendor/github.com/mgutz/ansi/print.go
generated
vendored
@ -1,57 +0,0 @@
|
|||||||
package ansi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"sort"
|
|
||||||
|
|
||||||
colorable "github.com/mattn/go-colorable"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PrintStyles prints all style combinations to the terminal.
|
|
||||||
func PrintStyles() {
|
|
||||||
// for compatibility with Windows, not needed for *nix
|
|
||||||
stdout := colorable.NewColorableStdout()
|
|
||||||
|
|
||||||
bgColors := []string{
|
|
||||||
"",
|
|
||||||
":black",
|
|
||||||
":red",
|
|
||||||
":green",
|
|
||||||
":yellow",
|
|
||||||
":blue",
|
|
||||||
":magenta",
|
|
||||||
":cyan",
|
|
||||||
":white",
|
|
||||||
}
|
|
||||||
|
|
||||||
keys := make([]string, 0, len(Colors))
|
|
||||||
for k := range Colors {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Sort(sort.StringSlice(keys))
|
|
||||||
|
|
||||||
for _, fg := range keys {
|
|
||||||
for _, bg := range bgColors {
|
|
||||||
fmt.Fprintln(stdout, padColor(fg, []string{"" + bg, "+b" + bg, "+bh" + bg, "+u" + bg}))
|
|
||||||
fmt.Fprintln(stdout, padColor(fg, []string{"+s" + bg, "+i" + bg}))
|
|
||||||
fmt.Fprintln(stdout, padColor(fg, []string{"+uh" + bg, "+B" + bg, "+Bb" + bg /* backgrounds */, "" + bg + "+h"}))
|
|
||||||
fmt.Fprintln(stdout, padColor(fg, []string{"+b" + bg + "+h", "+bh" + bg + "+h", "+u" + bg + "+h", "+uh" + bg + "+h"}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func pad(s string, length int) string {
|
|
||||||
for len(s) < length {
|
|
||||||
s += " "
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func padColor(color string, styles []string) string {
|
|
||||||
buffer := ""
|
|
||||||
for _, style := range styles {
|
|
||||||
buffer += Color(pad(color+style, 20), color+style)
|
|
||||||
}
|
|
||||||
return buffer
|
|
||||||
}
|
|
7
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
7
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
@ -23,10 +23,6 @@ TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
|||||||
MOV a1+8(FP), A0
|
MOV a1+8(FP), A0
|
||||||
MOV a2+16(FP), A1
|
MOV a2+16(FP), A1
|
||||||
MOV a3+24(FP), A2
|
MOV a3+24(FP), A2
|
||||||
MOV $0, A3
|
|
||||||
MOV $0, A4
|
|
||||||
MOV $0, A5
|
|
||||||
MOV $0, A6
|
|
||||||
MOV trap+0(FP), A7 // syscall entry
|
MOV trap+0(FP), A7 // syscall entry
|
||||||
ECALL
|
ECALL
|
||||||
MOV A0, r1+32(FP) // r1
|
MOV A0, r1+32(FP) // r1
|
||||||
@ -44,9 +40,6 @@ TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
|||||||
MOV a1+8(FP), A0
|
MOV a1+8(FP), A0
|
||||||
MOV a2+16(FP), A1
|
MOV a2+16(FP), A1
|
||||||
MOV a3+24(FP), A2
|
MOV a3+24(FP), A2
|
||||||
MOV ZERO, A3
|
|
||||||
MOV ZERO, A4
|
|
||||||
MOV ZERO, A5
|
|
||||||
MOV trap+0(FP), A7 // syscall entry
|
MOV trap+0(FP), A7 // syscall entry
|
||||||
ECALL
|
ECALL
|
||||||
MOV A0, r1+32(FP)
|
MOV A0, r1+32(FP)
|
||||||
|
1
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
1
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
@ -23,6 +23,7 @@ const (
|
|||||||
HCI_CHANNEL_USER = 1
|
HCI_CHANNEL_USER = 1
|
||||||
HCI_CHANNEL_MONITOR = 2
|
HCI_CHANNEL_MONITOR = 2
|
||||||
HCI_CHANNEL_CONTROL = 3
|
HCI_CHANNEL_CONTROL = 3
|
||||||
|
HCI_CHANNEL_LOGGING = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
// Socketoption Level
|
// Socketoption Level
|
||||||
|
12
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
12
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
@ -9,12 +9,11 @@ package unix
|
|||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||||
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
|
||||||
var fcntl64Syscall uintptr = SYS_FCNTL
|
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||||
|
|
||||||
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
func fcntl(fd int, cmd, arg int) (int, error) {
|
||||||
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
|
|
||||||
var err error
|
var err error
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
err = errno
|
err = errno
|
||||||
@ -22,6 +21,11 @@ func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
|||||||
return int(valptr), err
|
return int(valptr), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
return fcntl(int(fd), cmd, arg)
|
||||||
|
}
|
||||||
|
|
||||||
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||||
|
29
vendor/golang.org/x/sys/unix/fdset.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/fdset.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Set adds fd to the set fds.
|
||||||
|
func (fds *FdSet) Set(fd int) {
|
||||||
|
fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear removes fd from the set fds.
|
||||||
|
func (fds *FdSet) Clear(fd int) {
|
||||||
|
fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns whether fd is in the set fds.
|
||||||
|
func (fds *FdSet) IsSet(fd int) bool {
|
||||||
|
return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero clears the set fds.
|
||||||
|
func (fds *FdSet) Zero() {
|
||||||
|
for i := range fds.Bits {
|
||||||
|
fds.Bits[i] = 0
|
||||||
|
}
|
||||||
|
}
|
2
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
2
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then
|
|||||||
# Use the Docker-based build system
|
# Use the Docker-based build system
|
||||||
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
||||||
$cmd docker build --tag generate:$GOOS $GOOS
|
$cmd docker build --tag generate:$GOOS $GOOS
|
||||||
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
|
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")" && /bin/pwd):/build generate:$GOOS
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
10
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
10
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@ -44,6 +44,7 @@ includes_AIX='
|
|||||||
#include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/termio.h>
|
#include <sys/termio.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -185,16 +186,19 @@ struct ltchars {
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/signalfd.h>
|
#include <sys/signalfd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
#include <linux/bpf.h>
|
#include <linux/bpf.h>
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
#include <linux/capability.h>
|
#include <linux/capability.h>
|
||||||
#include <linux/cryptouser.h>
|
#include <linux/cryptouser.h>
|
||||||
|
#include <linux/devlink.h>
|
||||||
#include <linux/errqueue.h>
|
#include <linux/errqueue.h>
|
||||||
#include <linux/falloc.h>
|
#include <linux/falloc.h>
|
||||||
#include <linux/fanotify.h>
|
#include <linux/fanotify.h>
|
||||||
#include <linux/filter.h>
|
#include <linux/filter.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
#include <linux/fscrypt.h>
|
||||||
#include <linux/genetlink.h>
|
#include <linux/genetlink.h>
|
||||||
#include <linux/hdreg.h>
|
#include <linux/hdreg.h>
|
||||||
#include <linux/icmpv6.h>
|
#include <linux/icmpv6.h>
|
||||||
@ -494,7 +498,9 @@ ccflags="$@"
|
|||||||
$2 ~ /^CAN_/ ||
|
$2 ~ /^CAN_/ ||
|
||||||
$2 ~ /^CAP_/ ||
|
$2 ~ /^CAP_/ ||
|
||||||
$2 ~ /^ALG_/ ||
|
$2 ~ /^ALG_/ ||
|
||||||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
|
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ ||
|
||||||
|
$2 ~ /^FS_IOC_.*ENCRYPTION/ ||
|
||||||
|
$2 ~ /^FSCRYPT_/ ||
|
||||||
$2 ~ /^GRND_/ ||
|
$2 ~ /^GRND_/ ||
|
||||||
$2 ~ /^RND/ ||
|
$2 ~ /^RND/ ||
|
||||||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||||
@ -521,9 +527,11 @@ ccflags="$@"
|
|||||||
$2 ~ /^WDIOC_/ ||
|
$2 ~ /^WDIOC_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
$2 ~ /^XDP_/ ||
|
$2 ~ /^XDP_/ ||
|
||||||
|
$2 ~ /^RWF_/ ||
|
||||||
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
||||||
$2 ~ /^CRYPTO_/ ||
|
$2 ~ /^CRYPTO_/ ||
|
||||||
$2 ~ /^TIPC_/ ||
|
$2 ~ /^TIPC_/ ||
|
||||||
|
$2 ~ /^DEVLINK_/ ||
|
||||||
$2 !~ "WMESGLEN" &&
|
$2 !~ "WMESGLEN" &&
|
||||||
$2 ~ /^W[A-Z0-9]+$/ ||
|
$2 ~ /^W[A-Z0-9]+$/ ||
|
||||||
$2 ~/^PPPIOC/ ||
|
$2 ~/^PPPIOC/ ||
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
@ -510,6 +510,23 @@ func SysctlRaw(name string, args ...int) ([]byte, error) {
|
|||||||
return buf[:n], nil
|
return buf[:n], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SysctlClockinfo(name string) (*Clockinfo, error) {
|
||||||
|
mib, err := sysctlmib(name)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
n := uintptr(SizeofClockinfo)
|
||||||
|
var ci Clockinfo
|
||||||
|
if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if n != SizeofClockinfo {
|
||||||
|
return nil, EIO
|
||||||
|
}
|
||||||
|
return &ci, nil
|
||||||
|
}
|
||||||
|
|
||||||
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
//sys utimes(path string, timeval *[2]Timeval) (err error)
|
||||||
|
|
||||||
func Utimes(path string, tv []Timeval) error {
|
func Utimes(path string, tv []Timeval) error {
|
||||||
@ -577,8 +594,6 @@ func Futimes(fd int, tv []Timeval) error {
|
|||||||
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||||
}
|
}
|
||||||
|
|
||||||
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
|
||||||
|
|
||||||
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
//sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
|
||||||
|
|
||||||
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
func Poll(fds []PollFd, timeout int) (n int, err error) {
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
@ -155,23 +155,6 @@ func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (
|
|||||||
|
|
||||||
//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
||||||
|
|
||||||
func SysctlClockinfo(name string) (*Clockinfo, error) {
|
|
||||||
mib, err := sysctlmib(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
n := uintptr(SizeofClockinfo)
|
|
||||||
var ci Clockinfo
|
|
||||||
if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if n != SizeofClockinfo {
|
|
||||||
return nil, EIO
|
|
||||||
}
|
|
||||||
return &ci, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//sysnb pipe() (r int, w int, err error)
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
@ -333,6 +316,8 @@ func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
|
|||||||
* Wrapped
|
* Wrapped
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
||||||
|
|
||||||
//sys kill(pid int, signum int, posix int) (err error)
|
//sys kill(pid int, signum int, posix int) (err error)
|
||||||
|
|
||||||
func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
|
func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_darwin_arm.1_11.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_darwin_arm.1_11.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin,386,!go1.12
|
// +build darwin,arm,!go1.12
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
129
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
129
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
@ -1575,7 +1575,6 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys Fchdir(fd int) (err error)
|
//sys Fchdir(fd int) (err error)
|
||||||
//sys Fchmod(fd int, mode uint32) (err error)
|
//sys Fchmod(fd int, mode uint32) (err error)
|
||||||
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
||||||
//sys fcntl(fd int, cmd int, arg int) (val int, err error)
|
|
||||||
//sys Fdatasync(fd int) (err error)
|
//sys Fdatasync(fd int) (err error)
|
||||||
//sys Fgetxattr(fd int, attr string, dest []byte) (sz int, err error)
|
//sys Fgetxattr(fd int, attr string, dest []byte) (sz int, err error)
|
||||||
//sys FinitModule(fd int, params string, flags int) (err error)
|
//sys FinitModule(fd int, params string, flags int) (err error)
|
||||||
@ -1631,6 +1630,17 @@ func Getpgrp() (pid int) {
|
|||||||
//sysnb Settimeofday(tv *Timeval) (err error)
|
//sysnb Settimeofday(tv *Timeval) (err error)
|
||||||
//sys Setns(fd int, nstype int) (err error)
|
//sys Setns(fd int, nstype int) (err error)
|
||||||
|
|
||||||
|
// PrctlRetInt performs a prctl operation specified by option and further
|
||||||
|
// optional arguments arg2 through arg5 depending on option. It returns a
|
||||||
|
// non-negative integer that is returned by the prctl syscall.
|
||||||
|
func PrctlRetInt(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uintptr) (int, error) {
|
||||||
|
ret, _, err := Syscall6(SYS_PRCTL, uintptr(option), uintptr(arg2), uintptr(arg3), uintptr(arg4), uintptr(arg5), 0)
|
||||||
|
if err != 0 {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(ret), nil
|
||||||
|
}
|
||||||
|
|
||||||
// issue 1435.
|
// issue 1435.
|
||||||
// On linux Setuid and Setgid only affects the current thread, not the process.
|
// On linux Setuid and Setgid only affects the current thread, not the process.
|
||||||
// This does not match what most callers expect so we must return an error
|
// This does not match what most callers expect so we must return an error
|
||||||
@ -1666,6 +1676,123 @@ func Signalfd(fd int, sigmask *Sigset_t, flags int) (newfd int, err error) {
|
|||||||
//sys exitThread(code int) (err error) = SYS_EXIT
|
//sys exitThread(code int) (err error) = SYS_EXIT
|
||||||
//sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ
|
//sys readlen(fd int, p *byte, np int) (n int, err error) = SYS_READ
|
||||||
//sys writelen(fd int, p *byte, np int) (n int, err error) = SYS_WRITE
|
//sys writelen(fd int, p *byte, np int) (n int, err error) = SYS_WRITE
|
||||||
|
//sys readv(fd int, iovs []Iovec) (n int, err error) = SYS_READV
|
||||||
|
//sys writev(fd int, iovs []Iovec) (n int, err error) = SYS_WRITEV
|
||||||
|
//sys preadv(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) = SYS_PREADV
|
||||||
|
//sys pwritev(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr) (n int, err error) = SYS_PWRITEV
|
||||||
|
//sys preadv2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) = SYS_PREADV2
|
||||||
|
//sys pwritev2(fd int, iovs []Iovec, offs_l uintptr, offs_h uintptr, flags int) (n int, err error) = SYS_PWRITEV2
|
||||||
|
|
||||||
|
func bytes2iovec(bs [][]byte) []Iovec {
|
||||||
|
iovecs := make([]Iovec, len(bs))
|
||||||
|
for i, b := range bs {
|
||||||
|
iovecs[i].SetLen(len(b))
|
||||||
|
if len(b) > 0 {
|
||||||
|
iovecs[i].Base = &b[0]
|
||||||
|
} else {
|
||||||
|
iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iovecs
|
||||||
|
}
|
||||||
|
|
||||||
|
// offs2lohi splits offs into its lower and upper unsigned long. On 64-bit
|
||||||
|
// systems, hi will always be 0. On 32-bit systems, offs will be split in half.
|
||||||
|
// preadv/pwritev chose this calling convention so they don't need to add a
|
||||||
|
// padding-register for alignment on ARM.
|
||||||
|
func offs2lohi(offs int64) (lo, hi uintptr) {
|
||||||
|
return uintptr(offs), uintptr(uint64(offs) >> SizeofLong)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Readv(fd int, iovs [][]byte) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
n, err = readv(fd, iovecs)
|
||||||
|
readvRacedetect(iovecs, n, err)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
lo, hi := offs2lohi(offset)
|
||||||
|
n, err = preadv(fd, iovecs, lo, hi)
|
||||||
|
readvRacedetect(iovecs, n, err)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Preadv2(fd int, iovs [][]byte, offset int64, flags int) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
lo, hi := offs2lohi(offset)
|
||||||
|
n, err = preadv2(fd, iovecs, lo, hi, flags)
|
||||||
|
readvRacedetect(iovecs, n, err)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func readvRacedetect(iovecs []Iovec, n int, err error) {
|
||||||
|
if !raceenabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||||
|
m := int(iovecs[i].Len)
|
||||||
|
if m > n {
|
||||||
|
m = n
|
||||||
|
}
|
||||||
|
n -= m
|
||||||
|
if m > 0 {
|
||||||
|
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
raceAcquire(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Writev(fd int, iovs [][]byte) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
n, err = writev(fd, iovecs)
|
||||||
|
writevRacedetect(iovecs, n)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
lo, hi := offs2lohi(offset)
|
||||||
|
n, err = pwritev(fd, iovecs, lo, hi)
|
||||||
|
writevRacedetect(iovecs, n)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pwritev2(fd int, iovs [][]byte, offset int64, flags int) (n int, err error) {
|
||||||
|
iovecs := bytes2iovec(iovs)
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
lo, hi := offs2lohi(offset)
|
||||||
|
n, err = pwritev2(fd, iovecs, lo, hi, flags)
|
||||||
|
writevRacedetect(iovecs, n)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func writevRacedetect(iovecs []Iovec, n int) {
|
||||||
|
if !raceenabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||||
|
m := int(iovecs[i].Len)
|
||||||
|
if m > n {
|
||||||
|
m = n
|
||||||
|
}
|
||||||
|
n -= m
|
||||||
|
if m > 0 {
|
||||||
|
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// mmap varies by architecture; see syscall_linux_*.go.
|
// mmap varies by architecture; see syscall_linux_*.go.
|
||||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
28
vendor/golang.org/x/sys/unix/syscall_netbsd.go
generated
vendored
28
vendor/golang.org/x/sys/unix/syscall_netbsd.go
generated
vendored
@ -106,23 +106,6 @@ func direntNamlen(buf []byte) (uint64, bool) {
|
|||||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
|
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SysctlClockinfo(name string) (*Clockinfo, error) {
|
|
||||||
mib, err := sysctlmib(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
n := uintptr(SizeofClockinfo)
|
|
||||||
var ci Clockinfo
|
|
||||||
if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if n != SizeofClockinfo {
|
|
||||||
return nil, EIO
|
|
||||||
}
|
|
||||||
return &ci, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//sysnb pipe() (fd1 int, fd2 int, err error)
|
//sysnb pipe() (fd1 int, fd2 int, err error)
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
if len(p) != 2 {
|
if len(p) != 2 {
|
||||||
@ -249,6 +232,14 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
return sendfile(outfd, infd, offset, count)
|
return sendfile(outfd, infd, offset, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Fstatvfs(fd int, buf *Statvfs_t) (err error) {
|
||||||
|
return Fstatvfs1(fd, buf, ST_WAIT)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Statvfs(path string, buf *Statvfs_t) (err error) {
|
||||||
|
return Statvfs1(path, buf, ST_WAIT)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exposed directly
|
* Exposed directly
|
||||||
*/
|
*/
|
||||||
@ -262,6 +253,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys Close(fd int) (err error)
|
//sys Close(fd int) (err error)
|
||||||
//sys Dup(fd int) (nfd int, err error)
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
//sys Dup2(from int, to int) (err error)
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Dup3(from int, to int, flags int) (err error)
|
||||||
//sys Exit(code int)
|
//sys Exit(code int)
|
||||||
//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
//sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
//sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
|
||||||
@ -287,6 +279,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys Fpathconf(fd int, name int) (val int, err error)
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
||||||
|
//sys Fstatvfs1(fd int, buf *Statvfs_t, flags int) (err error) = SYS_FSTATVFS1
|
||||||
//sys Fsync(fd int) (err error)
|
//sys Fsync(fd int) (err error)
|
||||||
//sys Ftruncate(fd int, length int64) (err error)
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
//sysnb Getegid() (egid int)
|
//sysnb Getegid() (egid int)
|
||||||
@ -343,6 +336,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sysnb Settimeofday(tp *Timeval) (err error)
|
//sysnb Settimeofday(tp *Timeval) (err error)
|
||||||
//sysnb Setuid(uid int) (err error)
|
//sysnb Setuid(uid int) (err error)
|
||||||
//sys Stat(path string, stat *Stat_t) (err error)
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys Statvfs1(path string, buf *Statvfs_t, flags int) (err error) = SYS_STATVFS1
|
||||||
//sys Symlink(path string, link string) (err error)
|
//sys Symlink(path string, link string) (err error)
|
||||||
//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
|
//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
|
||||||
//sys Sync() (err error)
|
//sys Sync() (err error)
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
@ -55,23 +55,6 @@ func direntNamlen(buf []byte) (uint64, bool) {
|
|||||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
|
return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
|
||||||
}
|
}
|
||||||
|
|
||||||
func SysctlClockinfo(name string) (*Clockinfo, error) {
|
|
||||||
mib, err := sysctlmib(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
n := uintptr(SizeofClockinfo)
|
|
||||||
var ci Clockinfo
|
|
||||||
if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if n != SizeofClockinfo {
|
|
||||||
return nil, EIO
|
|
||||||
}
|
|
||||||
return &ci, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SysctlUvmexp(name string) (*Uvmexp, error) {
|
func SysctlUvmexp(name string) (*Uvmexp, error) {
|
||||||
mib, err := sysctlmib(name)
|
mib, err := sysctlmib(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -248,6 +231,7 @@ func Uname(uname *Utsname) error {
|
|||||||
//sys Close(fd int) (err error)
|
//sys Close(fd int) (err error)
|
||||||
//sys Dup(fd int) (nfd int, err error)
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
//sys Dup2(from int, to int) (err error)
|
//sys Dup2(from int, to int) (err error)
|
||||||
|
//sys Dup3(from int, to int, flags int) (err error)
|
||||||
//sys Exit(code int)
|
//sys Exit(code int)
|
||||||
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
//sys Fchdir(fd int) (err error)
|
//sys Fchdir(fd int) (err error)
|
||||||
@ -352,7 +336,6 @@ func Uname(uname *Utsname) error {
|
|||||||
// clock_settime
|
// clock_settime
|
||||||
// closefrom
|
// closefrom
|
||||||
// execve
|
// execve
|
||||||
// fcntl
|
|
||||||
// fhopen
|
// fhopen
|
||||||
// fhstat
|
// fhstat
|
||||||
// fhstatfs
|
// fhstatfs
|
||||||
|
12
vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go
generated
vendored
12
vendor/golang.org/x/sys/unix/zerrors_aix_ppc.go
generated
vendored
@ -459,6 +459,15 @@ const (
|
|||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
MAP_TYPE = 0xf0
|
MAP_TYPE = 0xf0
|
||||||
MAP_VARIABLE = 0x0
|
MAP_VARIABLE = 0x0
|
||||||
|
MCAST_BLOCK_SOURCE = 0x40
|
||||||
|
MCAST_EXCLUDE = 0x2
|
||||||
|
MCAST_INCLUDE = 0x1
|
||||||
|
MCAST_JOIN_GROUP = 0x3e
|
||||||
|
MCAST_JOIN_SOURCE_GROUP = 0x42
|
||||||
|
MCAST_LEAVE_GROUP = 0x3f
|
||||||
|
MCAST_LEAVE_SOURCE_GROUP = 0x43
|
||||||
|
MCAST_SOURCE_FILTER = 0x49
|
||||||
|
MCAST_UNBLOCK_SOURCE = 0x41
|
||||||
MCL_CURRENT = 0x100
|
MCL_CURRENT = 0x100
|
||||||
MCL_FUTURE = 0x200
|
MCL_FUTURE = 0x200
|
||||||
MSG_ANY = 0x4
|
MSG_ANY = 0x4
|
||||||
@ -483,6 +492,7 @@ const (
|
|||||||
MS_INVALIDATE = 0x40
|
MS_INVALIDATE = 0x40
|
||||||
MS_PER_SEC = 0x3e8
|
MS_PER_SEC = 0x3e8
|
||||||
MS_SYNC = 0x20
|
MS_SYNC = 0x20
|
||||||
|
NFDBITS = 0x20
|
||||||
NL0 = 0x0
|
NL0 = 0x0
|
||||||
NL1 = 0x4000
|
NL1 = 0x4000
|
||||||
NL2 = 0x8000
|
NL2 = 0x8000
|
||||||
@ -688,7 +698,7 @@ const (
|
|||||||
SIOCGHIWAT = 0x40047301
|
SIOCGHIWAT = 0x40047301
|
||||||
SIOCGIFADDR = -0x3fd796df
|
SIOCGIFADDR = -0x3fd796df
|
||||||
SIOCGIFADDRS = 0x2000698c
|
SIOCGIFADDRS = 0x2000698c
|
||||||
SIOCGIFBAUDRATE = -0x3fd79693
|
SIOCGIFBAUDRATE = -0x3fdf9669
|
||||||
SIOCGIFBRDADDR = -0x3fd796dd
|
SIOCGIFBRDADDR = -0x3fd796dd
|
||||||
SIOCGIFCONF = -0x3ff796bb
|
SIOCGIFCONF = -0x3ff796bb
|
||||||
SIOCGIFCONFGLOB = -0x3ff79670
|
SIOCGIFCONFGLOB = -0x3ff79670
|
||||||
|
12
vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go
generated
vendored
12
vendor/golang.org/x/sys/unix/zerrors_aix_ppc64.go
generated
vendored
@ -459,6 +459,15 @@ const (
|
|||||||
MAP_SHARED = 0x1
|
MAP_SHARED = 0x1
|
||||||
MAP_TYPE = 0xf0
|
MAP_TYPE = 0xf0
|
||||||
MAP_VARIABLE = 0x0
|
MAP_VARIABLE = 0x0
|
||||||
|
MCAST_BLOCK_SOURCE = 0x40
|
||||||
|
MCAST_EXCLUDE = 0x2
|
||||||
|
MCAST_INCLUDE = 0x1
|
||||||
|
MCAST_JOIN_GROUP = 0x3e
|
||||||
|
MCAST_JOIN_SOURCE_GROUP = 0x42
|
||||||
|
MCAST_LEAVE_GROUP = 0x3f
|
||||||
|
MCAST_LEAVE_SOURCE_GROUP = 0x43
|
||||||
|
MCAST_SOURCE_FILTER = 0x49
|
||||||
|
MCAST_UNBLOCK_SOURCE = 0x41
|
||||||
MCL_CURRENT = 0x100
|
MCL_CURRENT = 0x100
|
||||||
MCL_FUTURE = 0x200
|
MCL_FUTURE = 0x200
|
||||||
MSG_ANY = 0x4
|
MSG_ANY = 0x4
|
||||||
@ -483,6 +492,7 @@ const (
|
|||||||
MS_INVALIDATE = 0x40
|
MS_INVALIDATE = 0x40
|
||||||
MS_PER_SEC = 0x3e8
|
MS_PER_SEC = 0x3e8
|
||||||
MS_SYNC = 0x20
|
MS_SYNC = 0x20
|
||||||
|
NFDBITS = 0x40
|
||||||
NL0 = 0x0
|
NL0 = 0x0
|
||||||
NL1 = 0x4000
|
NL1 = 0x4000
|
||||||
NL2 = 0x8000
|
NL2 = 0x8000
|
||||||
@ -688,7 +698,7 @@ const (
|
|||||||
SIOCGHIWAT = 0x40047301
|
SIOCGHIWAT = 0x40047301
|
||||||
SIOCGIFADDR = -0x3fd796df
|
SIOCGIFADDR = -0x3fd796df
|
||||||
SIOCGIFADDRS = 0x2000698c
|
SIOCGIFADDRS = 0x2000698c
|
||||||
SIOCGIFBAUDRATE = -0x3fd79693
|
SIOCGIFBAUDRATE = -0x3fdf9669
|
||||||
SIOCGIFBRDADDR = -0x3fd796dd
|
SIOCGIFBRDADDR = -0x3fd796dd
|
||||||
SIOCGIFCONF = -0x3fef96bb
|
SIOCGIFCONF = -0x3fef96bb
|
||||||
SIOCGIFCONFGLOB = -0x3fef9670
|
SIOCGIFCONFGLOB = -0x3fef9670
|
||||||
|
5570
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
generated
vendored
5570
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5570
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
generated
vendored
5570
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5582
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
generated
vendored
5582
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5556
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
generated
vendored
5556
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
generated
vendored
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
generated
vendored
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
generated
vendored
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
generated
vendored
5574
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5692
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
generated
vendored
5692
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5692
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
generated
vendored
5692
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5544
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
generated
vendored
5544
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5690
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
generated
vendored
5690
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
generated
vendored
File diff suppressed because it is too large
Load Diff
5670
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
generated
vendored
5670
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
generated
vendored
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
// Code generated by linux/mkall.go generatePtracePair(arm, arm64). DO NOT EDIT.
|
// Code generated by linux/mkall.go generatePtracePair("arm", "arm64"). DO NOT EDIT.
|
||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build arm arm64
|
// +build arm arm64
|
17
vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go
generated
vendored
Normal file
17
vendor/golang.org/x/sys/unix/zptrace_linux_arm64.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Code generated by linux/mkall.go generatePtraceRegSet("arm64"). DO NOT EDIT.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// PtraceGetRegSetArm64 fetches the registers used by arm64 binaries.
|
||||||
|
func PtraceGetRegSetArm64(pid, addr int, regsout *PtraceRegsArm64) error {
|
||||||
|
iovec := Iovec{(*byte)(unsafe.Pointer(regsout)), uint64(unsafe.Sizeof(*regsout))}
|
||||||
|
return ptrace(PTRACE_GETREGSET, pid, uintptr(addr), uintptr(unsafe.Pointer(&iovec)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtraceSetRegSetArm64 sets the registers used by arm64 binaries.
|
||||||
|
func PtraceSetRegSetArm64(pid, addr int, regs *PtraceRegsArm64) error {
|
||||||
|
iovec := Iovec{(*byte)(unsafe.Pointer(regs)), uint64(unsafe.Sizeof(*regs))}
|
||||||
|
return ptrace(PTRACE_SETREGSET, pid, uintptr(addr), uintptr(unsafe.Pointer(&iovec)))
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by linux/mkall.go generatePtracePair(mips, mips64). DO NOT EDIT.
|
// Code generated by linux/mkall.go generatePtracePair("mips", "mips64"). DO NOT EDIT.
|
||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build mips mips64
|
// +build mips mips64
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by linux/mkall.go generatePtracePair(mipsle, mips64le). DO NOT EDIT.
|
// Code generated by linux/mkall.go generatePtracePair("mipsle", "mips64le"). DO NOT EDIT.
|
||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build mipsle mips64le
|
// +build mipsle mips64le
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT.
|
// Code generated by linux/mkall.go generatePtracePair("386", "amd64"). DO NOT EDIT.
|
||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build 386 amd64
|
// +build 386 amd64
|
22
vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go
generated
vendored
22
vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_11.go
generated
vendored
@ -239,17 +239,6 @@ func futimes(fd int, timeval *[2]Timeval) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
|
||||||
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
|
|
||||||
val = int(r0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
||||||
r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
||||||
n = int(r0)
|
n = int(r0)
|
||||||
@ -527,6 +516,17 @@ func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintp
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
|
val = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func kill(pid int, signum int, posix int) (err error) {
|
func kill(pid int, signum int, posix int) (err error) {
|
||||||
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
|
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
32
vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
generated
vendored
32
vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
generated
vendored
@ -339,22 +339,6 @@ func libc_futimes_trampoline()
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
|
||||||
r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
|
|
||||||
val = int(r0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func libc_fcntl_trampoline()
|
|
||||||
|
|
||||||
//go:linkname libc_fcntl libc_fcntl
|
|
||||||
//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
||||||
r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
||||||
n = int(r0)
|
n = int(r0)
|
||||||
@ -727,6 +711,22 @@ func libc_setattrlist_trampoline()
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
||||||
|
r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
|
val = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func libc_fcntl_trampoline()
|
||||||
|
|
||||||
|
//go:linkname libc_fcntl libc_fcntl
|
||||||
|
//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func kill(pid int, signum int, posix int) (err error) {
|
func kill(pid int, signum int, posix int) (err error) {
|
||||||
_, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
|
_, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
6
vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
generated
vendored
6
vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
generated
vendored
@ -44,8 +44,6 @@ TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
|
|||||||
JMP libc_utimes(SB)
|
JMP libc_utimes(SB)
|
||||||
TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_futimes(SB)
|
JMP libc_futimes(SB)
|
||||||
TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
|
|
||||||
JMP libc_fcntl(SB)
|
|
||||||
TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_poll(SB)
|
JMP libc_poll(SB)
|
||||||
TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
|
||||||
@ -84,6 +82,8 @@ TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
|
|||||||
JMP libc_flistxattr(SB)
|
JMP libc_flistxattr(SB)
|
||||||
TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_setattrlist(SB)
|
JMP libc_setattrlist(SB)
|
||||||
|
TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_fcntl(SB)
|
||||||
TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_kill(SB)
|
JMP libc_kill(SB)
|
||||||
TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
|
||||||
@ -106,6 +106,8 @@ TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
|
|||||||
JMP libc_chown(SB)
|
JMP libc_chown(SB)
|
||||||
TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_chroot(SB)
|
JMP libc_chroot(SB)
|
||||||
|
TEXT ·libc_clock_gettime_trampoline(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_clock_gettime(SB)
|
||||||
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_close(SB)
|
JMP libc_close(SB)
|
||||||
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
|
||||||
|
22
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go
generated
vendored
22
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_11.go
generated
vendored
@ -239,17 +239,6 @@ func futimes(fd int, timeval *[2]Timeval) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
|
||||||
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
|
|
||||||
val = int(r0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
||||||
r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
||||||
n = int(r0)
|
n = int(r0)
|
||||||
@ -527,6 +516,17 @@ func setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintp
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
||||||
|
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
|
val = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func kill(pid int, signum int, posix int) (err error) {
|
func kill(pid int, signum int, posix int) (err error) {
|
||||||
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
|
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
32
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
generated
vendored
32
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
generated
vendored
@ -339,22 +339,6 @@ func libc_futimes_trampoline()
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
|
||||||
r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
|
|
||||||
val = int(r0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func libc_fcntl_trampoline()
|
|
||||||
|
|
||||||
//go:linkname libc_fcntl libc_fcntl
|
|
||||||
//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
func poll(fds *PollFd, nfds int, timeout int) (n int, err error) {
|
||||||
r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
r0, _, e1 := syscall_syscall(funcPC(libc_poll_trampoline), uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
||||||
n = int(r0)
|
n = int(r0)
|
||||||
@ -727,6 +711,22 @@ func libc_setattrlist_trampoline()
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fcntl(fd int, cmd int, arg int) (val int, err error) {
|
||||||
|
r0, _, e1 := syscall_syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
|
val = int(r0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func libc_fcntl_trampoline()
|
||||||
|
|
||||||
|
//go:linkname libc_fcntl libc_fcntl
|
||||||
|
//go:cgo_import_dynamic libc_fcntl fcntl "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func kill(pid int, signum int, posix int) (err error) {
|
func kill(pid int, signum int, posix int) (err error) {
|
||||||
_, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
|
_, _, e1 := syscall_syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), uintptr(posix))
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
|
4
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
generated
vendored
4
vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
generated
vendored
@ -44,8 +44,6 @@ TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
|
|||||||
JMP libc_utimes(SB)
|
JMP libc_utimes(SB)
|
||||||
TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_futimes(SB)
|
JMP libc_futimes(SB)
|
||||||
TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
|
|
||||||
JMP libc_fcntl(SB)
|
|
||||||
TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_poll_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_poll(SB)
|
JMP libc_poll(SB)
|
||||||
TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_madvise_trampoline(SB),NOSPLIT,$0-0
|
||||||
@ -84,6 +82,8 @@ TEXT ·libc_flistxattr_trampoline(SB),NOSPLIT,$0-0
|
|||||||
JMP libc_flistxattr(SB)
|
JMP libc_flistxattr(SB)
|
||||||
TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_setattrlist_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_setattrlist(SB)
|
JMP libc_setattrlist(SB)
|
||||||
|
TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_fcntl(SB)
|
||||||
TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
|
||||||
JMP libc_kill(SB)
|
JMP libc_kill(SB)
|
||||||
TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
|
TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user