# swarm-cli

> A simple filesystem-backed Swarm client. Works more like a version control system: saves data to plain files, pulls/pushes updates from/to the server. Works offline, reconnects automatically.

Latest version **1.2.2** (published 2016-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install swarm-cli
pnpm add swarm-cli
yarn add swarm-cli
bun add swarm-cli
```

Provides the command `swarm-cli`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2016-09-29 |
| First published | 2015-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2662 |
| Author | Victor Grishchenko |
| Maintainers | gritzko |

## Links

- npm: https://www.npmjs.com/package/swarm-cli
- Repository: https://github.com/gritzko/swarm
- Homepage: http://github.com/gritzko/swarm
- Issues: https://github.com/gritzko/swarm/issues
- npm.io page: https://npm.io/package/swarm-cli

## Dependencies (2)

- [commander](https://npm.io/package/commander.md) ^2.9.0
- [swarm-syncable](https://npm.io/package/swarm-syncable.md) ^1.2.0

## Recent versions

- 1.2.2 (latest) — 2016-09-29
- 1.0.8 (nightly) — 2015-12-23
- 1.2.1 — 2016-09-29
- 1.0.15 — 2016-01-06
- 1.0.14 — 2015-12-31
- 1.0.12 — 2015-12-25

## README

# Swarm command-line client

A simple filesystem-backed Swarm client. Works more like a version control
system: saves data to plain files, pulls/pushes updates from/to the server.
Works offline, reconnects automatically.

## Usage

    swarm [options] dbdir/

## Options

- [ ] `-- dbdir`: replica's home path (default: .)
- [ ] `-C --connect url` connect to a server, init a replica
    - [ ] ws://1.2.3.4:5/dbid WebSocket
    - [ ] wss://1.2.3.4:5/dbid WebSocket (secure)
    - [ ] tcp://1.2.3.4:5/dbid TCP
- [ ] `-u --update type/id` update (default: all the objects)
- [ ] `-c --create type`
- [ ] `-g --get type/id` 
    - [ ] `-r --recur depth` recursive retrieval (default: depth 1)
- [ ] `-p --put type/id` commit a manually edited JSON object
- [ ] `-o --op type/id` feed an op (args or stdin must contain op name, value)
    - [ ] `-n --name` op name
    - [ ] `-v --value` op value
- [ ] `-e --edit type/id` edit a JSON state, put when done (uses $EDITOR)
- [ ] `-l --log` list the log of pending ops (those not acked by the server)
- [ ] `-m --mute`    ignore connect/listen options in the db
- [ ] `-R --repl` run REPL
- [ ] `-E --exec` execute script(s), e.g. --exec init.js -e run.js
- [ ] `-T --trace` trace incoming/outgoing ops

## Examples

```bash
# install swarm client (see swarm-server on how to run a server)
$ npm i -g swarm-cli

# connect to the server, init the client
$ swarm -C tcp://gritzko:password@localhost:31415/testdb 

$ cd testdb/

# create an object
$ swarm --create LWWObject
/LWWObject#1GDBdW+Rgritzko01

# see the outer JSON state of the object
$ cat LWWObject/1GDBdW+Rgritzko01.json
{"_id":"1GDBdW+Rgritzko01","_version":"1GDBdW+Rgritzko01"}

# see the inner CRDT state (data+metadata)
$ cat LWWObject/.1GDBdW+Rgritzko01.~

# make a change to the object, see some client-server chit-chat
$ swarm --trace -o LWWObject/1GDBdW+Rgritzko01 -n FieldName -v FieldValue
...
< /LWWObject#1GDBdW+Rgritzko01!1GDBdk+Rgritzko01.FieldName FieldValue
> /LWWObject#1GDBdW+Rgritzko01!1GDBdk+Rgritzko01.FieldName FieldValue
...

# launch REPL, play with the JavaScript API
$ swarm --repl
≶ o = swarm.get('1GDBdW+Rgritzko01', obj => console.log(obj.get('FieldName')));
FieldValue
≶ o.set('FieldName', 'another value');
...
```

---
_Source: https://npm.io/package/swarm-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
