weso

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2016 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

weso

CLI for Websocket.

install

go get github.com/morikuni/weso/cmd/weso

Usage

$ cat template.txt
{{define "Name"}}{"name": "{{._1}}"}{{end}}

{{define "Decorate"}}{{._1}}{{._2}}{{._1}}{{end}}

{{define "Twice"}}{{._1}}{{._1}}{{end}}

$ weso -template template.txt ws://echo.websocket.org
> hello
<< hello
> .Name Jack
<< {"name": "Jack"}
> .Decorate *** "I'm Jack"
<< ***I'm Jack***
> .Twice Hello
<< HelloHello

Start line with dot . to use template.

Template

Template file is written in Go's standard template library.

Arguments for template are expanded to ._1, ._2 ... ._N.

License

MIT

Credit

weso uses

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyTemplate = &Template{
	make(map[string]*template.Template),
}

EmptyTemplate is empty Template.

View Source
var QuitRequest = errors.New("quit request")

QuitRequest is used when websocket should be closed.

Functions

func Completer

func Completer(t *Template) liner.Completer

Completer create liner.Completer from Template.

func Parse

func Parse(s string) []string

Parse parse string to template name and args.

Types

type CLI

type CLI struct {
	// contains filtered or unexported fields
}

CLI is interface for websocket.

func NewCLI

func NewCLI(conf *Config) (*CLI, error)

NewCLI create CLI from Config.

func (*CLI) Close

func (c *CLI) Close()

Close close connection.

func (*CLI) Receive

func (c *CLI) Receive() error

Receive receive messages and print them.

func (*CLI) Run

func (c *CLI) Run() error

Run start receive and send loop.

func (*CLI) Send

func (c *CLI) Send() error

Send read command from Stdin and send message.

type Config

type Config struct {
	URL      string
	Origin   string
	Template string
	Debug    bool
}

Config is configuration file for CLI.

func NewConfig

func NewConfig(args []string, errOut io.Writer) (*Config, bool)

NewConfig create Config and output error to `errOut`.

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template is used to expand template.

func NewTemplateFile

func NewTemplateFile(path string) (*Template, error)

NewTemplateFile create Template from file.

func (*Template) Apply

func (t *Template) Apply(name string, args ...string) ([]byte, error)

Apply apply `args` to template for `name`.

func (*Template) IsDefined

func (t *Template) IsDefined(name string) bool

IsDefined check if Template for `name` exists.

func (*Template) Names

func (t *Template) Names() []string

Names return template names.

Directories

Path Synopsis
cmd
weso command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址