Skip to content

jagoe/haste-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hastebin Client (in Go)

Yet another CLI for hastebin, this one written in Go. It is intended to be used similarly to the original haste client, but also be able to get/read hastes.
As an added bonus, there's also cross-platform support without dependencies on other tools.

It also supports client certificates for mTLS for some reason.

Installation

Navigate to the latest release and download the client for your OS and architecture.

Usage

Creating a haste

Without any arguments, haste reads from the STDIN:

cat file | haste

Provided with a file argument, haste will create a haste from the contents of that file and return the URL pointing to it:

url=$(haste file) # equivalent to cat file | haste
echo $url         # e.g. https://hastebin.com/ogoquyocaq

Reading a haste

haste can read a haste using the get command:

haste get <key>           # prints the haste contents to STDOUT
haste get <key> -o ./file # prints the haste contents to ./file

Help

For more detailed information on how haste can be used, use haste --help or look here:

haste v1.0.0
A hastebin client that can create hastes from files and STDIN and read hastes from a haste-server instance.

Usage:
  haste [file] [flags]
  haste [command]

Examples:
echo Test | haste
cat ./file | haste
haste ./file

Available Commands:
  get         Get a haste from the server
  help        Help about any command

Flags:
      --client-cert string       Client certificate path
      --client-cert-key string   Client certificate key path
  -c, --config string            Config file [$HOME/.haste-client-go.yaml]
  -h, --help                     help for haste
  -s, --server string            Server URL (default "https://hastebin.com")
  -v, --version                  Print the version number

Use "haste [command] --help" for more information about a command.

Config

The global flags can also be configured by creating $HOME/.haste-client-go.yaml or referencing a configuration file using the -c/--config flag.

server: <url>
clientCert: <file location> # expects a certificate file in PEM format
clientCertKey: <file location> # expects a certificate key file in PEM format

Build

Requires golang 1.15+.

If there is no release for your OS and architecture or if you want to build the binary yourself for other reasons, you can follow these steps:

git clone git@github.com:jagoe/haste-client-go.git        # clone this repo
cd haste-client-go
[GOARCH=<your architecture>] [GOOS=<your OS>] make build  # build client
sudo mv ./bin/haste /usr/local/bin/haste                  # move to a bin directory in your PATH

Author

Jakob Göbel (goebel.jakob@gmail.com)

License

Apache License 2.0