build: make rclone build with wasm

Needed to drop
- azureblob backend
- cache backend
- qingstor backend
- cachestats command
- ncdu command
This commit is contained in:
Nick Craig-Wood
2020-08-10 17:32:21 +01:00
parent ac044b1c54
commit 3a14b1d5a9
34 changed files with 96 additions and 50 deletions
+1 -12
View File
@@ -9,7 +9,6 @@ import (
"sync"
colorable "github.com/mattn/go-colorable"
"golang.org/x/crypto/ssh/terminal"
)
// VT100 codes
@@ -72,7 +71,7 @@ var (
func Start() {
once.Do(func() {
f := os.Stdout
if !terminal.IsTerminal(int(f.Fd())) {
if !IsTerminal(int(f.Fd())) {
// If stdout not a tty then remove escape codes
Out = colorable.NewNonColorable(f)
} else if runtime.GOOS == "windows" && os.Getenv("TERM") != "" {
@@ -89,16 +88,6 @@ func WriteString(s string) {
Write([]byte(s))
}
// GetSize reads the dimensions of the current terminal or returns a
// sensible default
func GetSize() (w, h int) {
w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
if err != nil {
w, h = 80, 25
}
return w, h
}
// Out is an io.Writer which can be used to write to the terminal
// eg for use with fmt.Fprintf(terminal.Out, "terminal fun: %d\n", n)
var Out io.Writer
+31
View File
@@ -0,0 +1,31 @@
//+build !js
package terminal
import (
"os"
"golang.org/x/crypto/ssh/terminal"
)
// GetSize reads the dimensions of the current terminal or returns a
// sensible default
func GetSize() (w, h int) {
w, h, err := terminal.GetSize(int(os.Stdout.Fd()))
if err != nil {
w, h = 80, 25
}
return w, h
}
// IsTerminal returns whether the fd passed in is a terminal or not
func IsTerminal(fd int) bool {
return terminal.IsTerminal(fd)
}
// ReadPassword reads a line of input from a terminal without local echo. This
// is commonly used for inputting passwords and other sensitive data. The slice
// returned does not include the \n.
func ReadPassword(fd int) ([]byte, error) {
return terminal.ReadPassword(fd)
}
+23
View File
@@ -0,0 +1,23 @@
//+build js
package terminal
import "errors"
// GetSize reads the dimensions of the current terminal or returns a
// sensible default
func GetSize() (w, h int) {
return 80, 25
}
// IsTerminal returns whether the fd passed in is a terminal or not
func IsTerminal(fd int) bool {
return false
}
// ReadPassword reads a line of input from a terminal without local echo. This
// is commonly used for inputting passwords and other sensitive data. The slice
// returned does not include the \n.
func ReadPassword(fd int) ([]byte, error) {
return nil, errors.New("can't read password")
}