diff --git a/README.md b/README.md index af8f382..507bf1a 100644 --- a/README.md +++ b/README.md @@ -18,91 +18,147 @@ go get github.com/pocke/lemonade Or download from [latest release](https://github.com/pocke/lemonade/releases/latest) -Usage ------ +Example of use +---------------- -Default port is `2489`. +![Example](http://f.st-hatena.com/images/fotolife/P/Pocke/20150823/20150823173041.gif) +For example, you use a Linux as a virtual machine on Windows host. +You connect to Linux by SSH client(e.g. PuTTY). +When you want to copy text of a file on Linux to Windows, what do you do? +One solution is doing `cat file.txt` and drag displayed text. +But this answer is NOT elegant! Because your hand leaves from the keyboard to use the mouse. -### Server +Another solution is using the Lemonade. +You input `cat file.txt | lemonade copy`. Then, lemonade copies text of the file to clipboard of the Windows! -```sh -lemonade server --port 1234 -``` +In addition to the above, lemonade supports pasting and opening URL. -### Client -`192.168.xx.xx` is a IP address of lemonade Server. - -#### Open browser +Usage +-------- ```sh -lemonade open --port 1234 --host '192.168.xx.xx' 'http://example.com' -# or -echo 'http://example.com' | lemonade open --port 1234 --host '192.168.xx.xx' +Usage: lemonade [options]... SUB_COMMAND [arg] +Sub Commands: + open [URL] Open URL by browser + copy [text] Copy text. + paste Paste text. + server Start lemonade server. + +Options: + --port=2489 TCP port number + --allow="0.0.0.0/0,::0" Allow IP Range [Server only] + --host="localhost" Destination hostname [Client only] + --trans-loopback=true Translate loopback address [open subcommand only] + --trans-localfile=true Translate local file path [open subcommand only] + --help Show this message ``` -`http://example.com` is opened by browser on Server. - - -#### Copy +### On server (in the above, Windows) ```sh -lemonade open --port 1234 --host '192.168.xx.xx' 'hogefuga' -# or -echo 'hogefuga' | lemonade open --port 1234 --host '192.168.xx.xx' +$ lemonade server ``` -`hogefuga` is copied to Server. +### Client (in the above, Linux) -#### Paste ```sh -lemonade open --port 1234 --host '192.168.xx.xx' -# => hogefuga -``` +# You want to copy a text +$ cat file.txt | lemonade copy -`hogefuga` is a clipboard value of Server. +# You want to paste a text from the clipboard of Windows +$ lemonade paste +# You want to open an URL to a browser on Windows. +$ lemonade open 'http://google.com' +``` Configuration --------------- +--------------- You can override command line options by configuration file. +There is configuration file at `~/.config/lemonade.toml`. ### Server -`~/.config/lemonade.toml` - ```toml port = 1234 allow = '192.168.0.0/24' ``` -`allow` is a comma separated list of allowed IP(and subnet mask) or an allowed IP. -Default value is `0.0.0.0/0,::0`(allowed from all IP). +- `port` is a listening port of TCP. +- `allow` is a comma separated list of a allowed IP address(with CIDR block). -### Client -`~/.config/lemonade.toml` +### Client ```toml port = 1234 host = '192.168.x.x' +trans-loopback = true +trans-localfile = true ``` +- `port` is a port of server. +- `host` is a hostname of server. +- `trans-loopback` is a flag of translation loopback address. +- `trans-localfile` is a flag of translation localfile. + +Detail of `trans-loopback` and `trans-localfile` are described Advanced Usage. + + +Advanced Usage +----------------- + + +### trans-loopback + +Default: true + +This option works with `open` command only. + +If this option is true, lemonade translates loopback address to address of client. + +For example, you input `lemonade open 'http://127.0.0.1:8000'`. +If this option is false, server receives loopback address. +But this isn't expected. +Because, at server, loopback address is server itself. + +If this option is true, server receives IP address of client. +So, server can open URL! + + +### trans-localfile + +Default: true + +This option works with `open` command only. + +If this option is true, lemonade translates path of local file to address of client. + +For example, you input `lemonade open ./file.txt`. +If this option is false, server receives `./file.txt`. +But this isn't expected. +Because, at server, `./file.txt` doesn't exist. + +If this option is true, server receives IP address of client. And client serve the local file. +So, server can open the local file! + + + +### Alias -Alias ------ +You can use lemonade as a `xdg-open`, `pbcopy` and `pbpaste`. -You can use lemonade as a `xdg-open` , `pbcopy` and `pbpaste`. For example. ```sh -ln -s /path/to/lemonade /usr/bin/xdg-open -xdg-open 'http://example.com' # Same as lemonade open 'http://example.com' +$ ln -s /path/to/lemonade /usr/bin/xdg-open +$ xdg-open 'http://example.com' # Same as lemonade open 'http://example.com' ```