Features

Terminal

Content managed by Snippy is divided into two categories called snippets and solutions. Snippets are short command examples and solutions are longer solution descriptions. You can add metadata like links and tags to help to search content.

You can operate snippet or solution content with six basic operations: create, search, update, delete, import and export. These operations manage the content in persistent file storage installed into the same place as the tool.

Server

You can run the Snippy as a server. The server can create, search, update and delete snippets and solutions. The server operates through RESTish API that follows a subset of JSON API v1.0 specification.

The server does not bind to any address by default and the server-host option must be always defined. The server-host option supports format <ip>:<port. You can also define the log format between string and JSON and verbosity level of logs.

The API is experimental and changes can be expected. The API is documented in Swagger Hub OpenAPI definitions.

The JSON REST API server is available only when the tool is installed from Docker Hub or directly from the source code.

# Start server by sharing host network and enable JSON logs with limited
# message length. Always remove previosly started container before running
# container with new options set.
docker rm -f snippy
sudo docker run -d --net="host" --name snippy heilaaks/snippy --server-host 127.0.0.1:8080 --log-json -vv
curl -s -X GET "http://127.0.0.1:8080/api/snippy/rest/snippets?limit=2" -H "accept: application/vnd.api+json" | python -m json.tool
curl -X GET "http://127.0.0.1:8080/api/snippy/rest/snippets?sall=docker&limit=2" -H "accept: application/vnd.api+json" | python -m json.tool

# Start the server and define the port and IP address when the network is
# shared between the container and host. Generate full length logs with
# the --debug option.
docker rm -f snippy
sudo docker run -d --net="host" --name snippy heilaaks/snippy --server-host 127.0.0.1:8080 --log-json --debug
curl -s -X GET "http://127.0.0.1:8080/api/snippy/rest/snippets?sall=docker&limit=2" -H "accept: application/vnd.api+json" | python -m json.tool

# Run the server with string logs.
docker rm -f snippy
sudo docker run -d --net="host" --name snippy heilaaks/snippy --server-host 127.0.0.1:8080 -vv

You can query the server logs with the Docker log command.

docker logs snippy

You can remove the server with the rm command.

docker rm -f snippy

Note that Docker container is immutable and it does not share volume from the host. If you want to run a server that allows content modification, you must install the server from code repository.

git clone https://github.com/heilaaks/snippy.git
cd snippy
make server

With a local server, you can change to location of the storage from the default. If the default content is needed, you need to import it into the new location before starting the server.

snippy import --defaults --storage-path ${HOME}/devel/temp
snippy import --defaults --solution --storage-path ${HOME}/devel/temp
snippy --server-host 127.0.0.1:8080 --storage-path ${HOME}/devel/temp -vv