Skip to content

plebbit/plebbit-cli

Repository files navigation

Commitizen friendly

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.

  • Runs an IPFS and Plebbit node
  • Command Line interface Interface to IPFS-Nodes
  • WebSocket RPC to access and control your subplebbits and publications

Install

For Linux/MacOS

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

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:

  • macOS: ~/Library/Application Support/plebbit
  • Windows: %LOCALAPPDATA%\plebbit
  • Linux: ~/.local/share/plebbit

The logs directory of Plebbit

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

  • macOS: ~/Library/Logs/plebbit
  • Windows: %LOCALAPPDATA%\plebbit\Log
  • Linux: ~/.local/state/plebbit

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

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 --plebbitDataPath <value> --plebbitRpcPort <value> --ipfsApiPort <value>
    --ipfsGatewayPort <value>

FLAGS
  --ipfsApiPort=<value>      (required) [default: 5001] Specify the API port of the ipfs node to listen on
  --ipfsGatewayPort=<value>  (required) [default: 6473] Specify the gateway port of the ipfs node to listen on
  --plebbitDataPath=<value>  (required) [default: /home/runner/.local/share/plebbit] Path to plebbit data path where
                             subplebbits and ipfs node are stored
  --plebbitRpcPort=<value>   (required) [default: 9138] Specify Plebbit RPC port 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

EXAMPLES
  $ plebbit daemon

  $ plebbit daemon --plebbitRpcPort 80

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 --plebbitRpcApiUrl <value> [--privateKeyPath <value>]

FLAGS
  --plebbitRpcApiUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC API
  --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 --plebbitRpcApiUrl <value>

ARGUMENTS
  ADDRESS  Address of the subplebbit address to edit

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

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"

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 --plebbitRpcApiUrl <value>

ARGUMENTS
  ADDRESS  Address of the subplebbit address to fetch

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

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 --plebbitRpcApiUrl <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>
      --plebbitRpcApiUrl=<value>  (required) [default: ws://localhost:9138/] URL to Plebbit RPC API
      --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... --plebbitRpcApiUrl <value>

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

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

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... --plebbitRpcApiUrl <value>

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

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

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

Contribution

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

  • This repo follows Angular commit conventions. Easiest way to follow these conventions is by using yarn commit instead of git commit
  • If you're adding a feature, make sure to add tests to your pull requests

Feedback

We would love your feedback on our Telegram