Home

Awesome

Commitizen friendly

<img src="https://raw.githubusercontent.com/plebbit/assets/master/letters-grey.svg" width="260" height="73">

plebbit-cli: A Plebbit Node with WebSocket and Command Line Interface

Table of contents

What is Plebbit?

Plebbit is serverless, admin-less, decentralized Reddit alternative built completely with IPFS/IPNS/pubsub/ENS. It doesn't use any central server, central database, public HTTP endpoint or DNS, it is pure peer to peer (except for the web client that can't join a P2P swarm directly, web clients use interchangeable HTTP providers). It will allow subplebbit (subreddit) owners to retain full ownership over their community. Whitepaper here

What is plebbit-cli?

plebbit-cli is an interface to the backend of Plebbit using plebbit-js. Users can run and manage their subplebbits using it. It is written in Typescript and designed to receive commands via CLI and WebSocket.

Install

For Linux/MacOS

curl https://raw.githubusercontent.com/plebbit/plebbit-cli/master/bin/install.sh | sh

If you want to install a specific plebbit-cli version

curl https://raw.githubusercontent.com/plebbit/plebbit-cli/master/bin/install.sh | sh -s 0.14.4

If you get libfontconfig dependency error, then you need to install libfontconfig by running sudo apt install -y libfontconfig1 fontconfig libfontconfig1-dev libfontconfig

For Windows

For Windows, You need to install vc-redist first. After you install vc-redist, download the installer of plebbit and next your way to the end

Build your Plebbit executable manually (optional)

In case the installation script is not working for you or you just want to build the source code directly. First, Yyu need to have NodeJS 20, npm and yarn installed

git clone https://github.com/plebbit/plebbit-cli
cd plebbit-cli
yarn install --frozen-lockfile
yarn build
yarn oclif manifest
yarn ci:download-web-uis
./bin/run --help

After running the last command you should be able to run commands directly against ./bin/run, for example ./bin/run daemon

Usage

The data/config directory of Plebbit

This is the default directory where plebbit-cli will keep its config, as well as data for local subplebbits:

The logs directory of Plebbit

Plebbit-cli will keep logs in this directory, with a cap of 10M per log file.

Running Daemon

In Bash (or powershell if you're on Windows), run plebbit daemon to able to connect to the network. You need to have the plebbit daemon terminal running to be able to execute other commands.

$ plebbit daemon
IPFS API listening on: http://localhost:5001/api/v0
IPFS Gateway listening on: http://localhost:6473
plebbit rpc: listening on ws://localhost:9138 (local connections only)
plebbit rpc: listening on ws://localhost:9138/MHA1tm2QWG19z0bnkRarDNWIajDobl7iN2eM2PmL (secret auth key for remote connections)
Plebbit data path: /root/.local/share/plebbit
Subplebbits in data path:  [ 'pleblore.eth' ]
WebUI (plebones): http://localhost:9138/plebones (local connections only)
WebUI (plebones): http://192.168.1.60:9138/MHA1tm2QWG19z0bnkRarDNWIajDobl7iN2eM2PmL/plebones (secret auth key for remote connections)
WebUI (seedit): http://localhost:9138/seedit (local connections only)
WebUI (seedit): http://192.168.1.60:9138/MHA1tm2QWG19z0bnkRarDNWIajDobl7iN2eM2PmL/seedit (secret auth key for remote connections)

Once plebbit daemon is running, you can create and manage your subplebbits through the web interfaces, either seedit or plebones. If you're a power user and prefer CLI, then you can take a look at the commands below.

Creating your first sub

$ plebbit subplebbit create --title "Hello Plebs!" --description "This is gonna be great"
12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu

Listing all your subs

$ plebbit subplebbit list
Address                                              Started
 ──────────────────────────────────────────────────── ───────
 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu true
 business-and-finance.eth                             true
 censorship-watch.eth                                 true
 health-nutrition-science.eth                         true
 movies-tv-anime.eth                                  true
 pleblore.eth                                         true
 politically-incorrect.eth                            true
 reddit-screenshots.eth                               false
 videos-livestreams-podcasts.eth                      false

Adding a role moderator to your sub

$ plebbit subplebbit edit mysub.eth '--roles["author-address.eth"].role' moderator

Adding a role owner to your sub

$ plebbit subplebbit edit mysub.eth '--roles["author-address.eth"].role' owner

Adding a role admin to your sub

$ plebbit subplebbit edit mysub.eth '--roles["author-address.eth"].role' admin

Removing a role

$ plebbit subplebbit edit mysub.eth '--roles["author-address.eth"]' null

Commands

<!-- commands -->

plebbit daemon

Run a network-connected Plebbit node. Once the daemon is running you can create and start your subplebbits and receive publications from users. The daemon will also serve web ui on http that can be accessed through a browser on any machine. Within the web ui users are able to browse, create and manage their subs fully P2P.

USAGE
  $ plebbit daemon --plebbitRpcUrl <value> --ipfsApiUrl <value> --ipfsGatewayUrl <value> --logPath <value>

FLAGS
  --ipfsApiUrl=<value>      (required) [default: http://127.0.0.1:5001/api/v0] Specify the API URL of the ipfs node to
                            listen on
  --ipfsGatewayUrl=<value>  (required) [default: http://127.0.0.1:6473/] Specify the gateway port of the ipfs node to
                            listen on
  --logPath=<value>         (required) [default: /home/runner/.local/state/plebbit] Specify a directory which will be
                            used to store logs
  --plebbitRpcUrl=<value>   (required) [default: ws://localhost:9138/] Specify Plebbit RPC URL to listen on

DESCRIPTION
  Run a network-connected Plebbit node. Once the daemon is running you can create and start your subplebbits and receive
  publications from users. The daemon will also serve web ui on http that can be accessed through a browser on any
  machine. Within the web ui users are able to browse, create and manage their subs fully P2P.
  Options can be passed to the RPC's instance through flag --plebbitOptions.optionName. For a list of plebbit options
  (https://github.com/plebbit/plebbit-js?tab=readme-ov-file#plebbitoptions)

EXAMPLES
  $ plebbit daemon

  $ plebbit daemon --plebbitRpcUrl ws://localhost:53812

  $ plebbit daemon --plebbitOptions.dataPath /tmp/plebbit-datapath/

  $ plebbit daemon --plebbitOptions.chainProviders.eth[0].url https://ethrpc.com

  $ plebbit daemon --plebbitOptions.ipfsHttpClientsOption[0] http://remoteipfsnode.com

See code: src/cli/commands/daemon.ts

plebbit help [COMMAND]

Display help for plebbit.

USAGE
  $ plebbit help [COMMAND...] [-n]

ARGUMENTS
  COMMAND...  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for plebbit.

See code: @oclif/plugin-help

plebbit subplebbit create

Create a subplebbit with specific properties. A newly created sub will be started after creation and be able to receive publications. For a list of properties, visit https://github.com/plebbit/plebbit-js#subplebbiteditsubplebbiteditoptions

USAGE
  $ plebbit subplebbit create --plebbitRpcUrl <value> [--privateKeyPath <value>]

FLAGS
  --plebbitRpcUrl=<value>   (required) [default: ws://localhost:9138/] URL to Plebbit RPC
  --privateKeyPath=<value>  Private key (PEM) of the subplebbit signer that will be used to determine address (if
                            address is not a domain). If it's not provided then Plebbit will generate a private key

DESCRIPTION
  Create a subplebbit with specific properties. A newly created sub will be started after creation and be able to
  receive publications. For a list of properties, visit
  https://github.com/plebbit/plebbit-js#subplebbiteditsubplebbiteditoptions

EXAMPLES
  Create a subplebbit with title 'Hello Plebs' and description 'Welcome'

    $ plebbit subplebbit create --title 'Hello Plebs' --description 'Welcome'

See code: src/cli/commands/subplebbit/create.ts

plebbit subplebbit edit ADDRESS

Edit a subplebbit properties. For a list of properties, visit https://github.com/plebbit/plebbit-js#subplebbiteditsubplebbiteditoptions

USAGE
  $ plebbit subplebbit edit ADDRESS --plebbitRpcUrl <value>

ARGUMENTS
  ADDRESS  Address of the subplebbit address to edit

FLAGS
  --plebbitRpcUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC

DESCRIPTION
  Edit a subplebbit properties. For a list of properties, visit
  https://github.com/plebbit/plebbit-js#subplebbiteditsubplebbiteditoptions

EXAMPLES
  Change the address of the sub to a new ENS address

    $ plebbit subplebbit edit 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu --address newAddress.eth

  Add the author address 'esteban.eth' as an admin on the sub

    $ plebbit subplebbit edit mysub.eth '--roles["esteban.eth"].role' admin

  Add two challenges to the sub. The first challenge will be a question and answer, and the second will be an image
  captcha

    $ plebbit subplebbit edit mysub.eth --settings.challenges[0].name question \
      --settings.challenges[0].options.question "what is the password?" --settings.challenges[0].options.answer \
      thepassword --settings.challenges[1].name captcha-canvas-v3

  Change the title and description

    $ plebbit subplebbit edit mysub.eth --title "This is the new title" --description "This is the new description"

  Remove a role from a moderator/admin/owner

    $ plebbit subplebbit edit plebbit.eth --roles['rinse12.eth'] null

  Enable settings.fetchThumbnailUrls to fetch the thumbnail of url submitted by authors

    subplebbit edit plebbit.eth --settings.fetchThumbnailUrls

  disable settings.fetchThumbnailUrls

    subplebbit edit plebbit.eth --settings.fetchThumbnailUrls=false

See code: src/cli/commands/subplebbit/edit.ts

plebbit subplebbit get ADDRESS

Fetch a local or remote subplebbit, and print its json in the terminal

USAGE
  $ plebbit subplebbit get ADDRESS --plebbitRpcUrl <value>

ARGUMENTS
  ADDRESS  Address of the subplebbit address to fetch

FLAGS
  --plebbitRpcUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC

DESCRIPTION
  Fetch a local or remote subplebbit, and print its json in the terminal

EXAMPLES
  $ plebbit subplebbit get plebmusic.eth

  $ plebbit subplebbit get 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu

See code: src/cli/commands/subplebbit/get.ts

plebbit subplebbit list

List your subplebbits

USAGE
  $ plebbit subplebbit list --plebbitRpcUrl <value> [-q] [--columns <value> | -x] [--filter <value>] [--no-header |
    [--csv | --no-truncate]] [--output csv|json|yaml |  | ] [--sort <value>]

FLAGS
  -q, --quiet                  Only display subplebbit addresses
  -x, --extended               show extra columns
      --columns=<value>        only show provided columns (comma-separated)
      --csv                    output is csv format [alias: --output=csv]
      --filter=<value>         filter property by partial string matching, ex: name=foo
      --no-header              hide table header from output
      --no-truncate            do not truncate output to fit screen
      --output=<option>        output in a more machine friendly format
                               <options: csv|json|yaml>
      --plebbitRpcUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC
      --sort=<value>           property to sort by (prepend '-' for descending)

DESCRIPTION
  List your subplebbits

See code: src/cli/commands/subplebbit/list.ts

plebbit subplebbit start ADDRESSES

Start a subplebbit

USAGE
  $ plebbit subplebbit start ADDRESSES... --plebbitRpcUrl <value>

ARGUMENTS
  ADDRESSES...  Addresses of subplebbits to start. Separated by space

FLAGS
  --plebbitRpcUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC

DESCRIPTION
  Start a subplebbit

EXAMPLES
  $ plebbit subplebbit start plebbit.eth

  $ plebbit subplebbit start 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu

See code: src/cli/commands/subplebbit/start.ts

plebbit subplebbit stop ADDRESSES

Stop a subplebbit. The subplebbit will not publish or receive any publications until it is started again.

USAGE
  $ plebbit subplebbit stop ADDRESSES... --plebbitRpcUrl <value>

ARGUMENTS
  ADDRESSES...  Addresses of subplebbits to stop. Separated by space

FLAGS
  --plebbitRpcUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC

DESCRIPTION
  Stop a subplebbit. The subplebbit will not publish or receive any publications until it is started again.

EXAMPLES
  $ plebbit subplebbit stop plebbit.eth

  $ plebbit subplebbit stop Qmb99crTbSUfKXamXwZBe829Vf6w5w5TktPkb6WstC9RFW

See code: src/cli/commands/subplebbit/stop.ts

<!-- commandsstop -->

Contribution

We're always happy to receive pull requests. Few things to keep in mind:

Feedback

We would love your feedback on our Telegram