Giter VIP home page Giter VIP logo

claws.gocui's Introduction

claws demonstration

an Awesome WebSocket CLient

Claws

WebSockets have been on the rise for a long time, but there is no good command line client that allows to interface with websockets without having to deal with barebones interfaces. Claws aims to make testing websockets and interfacing with them easier and more pleasant.

Getting started

You can grab the latest release binary from the releases page. Simply download it, extract it, and run it in a command line.

If you have Go set up, it is easy as running the following command and making sure that $GOPATH/bin (or $GOBIN) is in your PATH. Generally, this should be pretty stable, but keep in mind that it builds on master, so it may break at any point.

go get -v -u howl.moe/claws

Usage

claws [wsURL]

wsURL is an optional websocket URL to connect to once the UI has been initialised.

Once the UI has been initialised, you will be by default in "normal mode": green box with nothing in it. This means you are composing a message to send to the server through the websocket. By pressing Esc, followed by a letter, you can do a variety of actions explained in the following table.

Letter Meaning
i Go to insert mode (also works by pressing the Ins key).
c Create a new WebSocket connection. Will prompt for an URL. If nothing is passed, previous WebSocket URL will be used.
q Close current WebSocket connection.

Quitting is done by pressing Ctrl-C. In previous version, you could press Esc twice to exit, but we decided to remove that because some vim aficionados (myself included) may find themselves panickingly pressing esc and accidentally quitting Claws.

If you want to scroll through the logs, while in Esc mode press the arrow keys, PgUp/PgDown, Home/End. Keep in mind that pressing any of these will disable autoscroll, so new elements from the log won't be shown unless you scroll down.

When you're typing text into the field, you can browse through the history of previous text, even in previous sessions, in a bash-like fashion.

Advanced usage

There are also more actions you can activate using ESC + key, that are generally not used on a day-to-day basis.

Letter Meaning
t Toggle timestamps before messages in console.
j Toggle auto-detection of JSON in server messages and automatic tab indentation.
h View help/welcome screen with quick commands.
R Go into replace/overtype mode (can also be done by pressing Insert a couple of times).

Configuration

Claws stores its configuration file in ~/.config/claws.json. You are welcome to hack it and change values to how you see fit. Here's a list of the values: obvious settings are ignored.

  • Timestamp: a timestamp with which all messages to the console should be prefixed. The defaults can be toggled using the t key in esc mode, although you can also use your own prefix, following Go's system of formatting dates. The default values are an empty string "" or "2006-01-02 15:04:05 ".
  • LastWebsocketURL: URL of the last websocket you connected to. Used when connecting using the c key without specifying an URL.
  • LastActions: 50 most recent messages you sent to the console, used for seeking through history using up and down.

Pipe

Piping allows you to log the messages you send and the messages you receive, or do any kind of pre-processing before they are sent or before they are shown on the console.

Pipes are specified by the Pipe configuration variable. It defaults to null - to set it, create an array containing in the first place a command and then the arguments for it. This should be a command available in your $PATH or an absolute path.

For UNIX system, this means you can do logging effectively using tee. The most basic form of logging may look like this:

"Pipe": {
	"In": ["tee", "-a", "received_messages.log"],
	"Out": ["tee", "-a", "sent_messages.log"]
}

This will append to the given log files the received and sent messages. But it doesn't have to stop there! You can really create any script that may do any pre-processing you want to the messages you receive and those you send. If you intend to write a non-trivial script, here are things that might come useful to know:

  • Any non-zero exit code will show an error on the console.
  • The program should be pretty fast to run, as the message can't be shown until the processing has finished.
  • There are some environment variables which provide information on the connection:
    • CLAWS_PIPE_TYPE: The type of pipe; either in or out.
    • CLAWS_SESSION: UNIX timestamp in microseconds of when the session was started.
    • CLAWS_CONNECTION: UNIX timestamp in microseconds of when the connection was started.
    • CLAWS_WS_URL: WebSocket URL we're connected to.

The sky is the limit here, so you can really do anything you can think of. Here are some examples (feel free to add more with a PR!):

Contributing

Claws is mostly feature-complete, though we have something that might interest you on our issue list. If, instead, you're interested in reporting a bug or asking for a new feature, you can create a new issue. There are no real contribution guidelines, but try to write some good Go code and use go fmt :).

claws.gocui's People

Contributors

davidelettieri avatar sl1pm4t avatar thehowl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.