Skip to content

Commit

Permalink
Updates CLI to use entropy tui.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymatthews committed Nov 5, 2024
1 parent 0e96df4 commit 60b2569
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 145 deletions.
4 changes: 2 additions & 2 deletions content/basics/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ The command-line interface (CLI) is the most straightforward way to interact wit
npm install --global @entropyxyz/cli
```

1. Run the CLI using `entropy`:
1. Run the CLI using `entropy tui`:

```shell
entropy
entropy tui
```

```output
Expand Down
4 changes: 2 additions & 2 deletions content/guides/deploy-a-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Next, you can move on to starting the CLI and deploying your program.

### Deploy the program

1. Start the CLI by running `entropy`.
1. Start the CLI by running `entropy tui`.
1. At the main menu within the CLI, select **Deploy Program**:

```output
Expand Down Expand Up @@ -50,7 +50,7 @@ You can now interact with your program using the program pointer.
If you've lost your program pointer, you can list it by running the following:
1. Start the CLI by running `entropy`.
1. Start the CLI by running `entropy tui`.
1. At the main menu within the CLI, select **Deploy Program**:
```output
Expand Down
4 changes: 2 additions & 2 deletions content/guides/manage-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You need to have the Entropy CLI installed. [Take a look at the CLI page for det

### Create an account

1. Start the CLI by running `entropy`.
1. Start the CLI by running `entropy tui`.
1. Select **Manage Accounts**.
1. Select **New**.
1. Type `n` and press `ENTER` when asked _Would you like to import a key?_:
Expand All @@ -36,7 +36,7 @@ You need to have the Entropy CLI installed. [Take a look at the CLI page for det

You can import an account by the `seed` for the account. Most Substrate-based wallets allow you to export your account information.

1. Start the CLI by running `entropy`.
1. Start the CLI by running `entropy tui`.
1. Select **Manage Accounts**.
1. Select **New**.
1. Type `y` and press `ENTER` when asked _Would you like to import a key?_:
Expand Down
2 changes: 1 addition & 1 deletion content/guides/register-an-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ lead: "Registering an account is a feature unique to Entropy. Without going into

Here is the process for registering an address using the Entropy CLI's interactive text-based user interface (TUI).

1. Start the CLI by running `entropy`.
1. Start the CLI by running `entropy tui`.
1. Back at the main menu within the CLI, select **Register**:

```output
Expand Down
292 changes: 154 additions & 138 deletions content/reference/command-line-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,26 @@
title: "Command-line interface"
lead: "The command-line interface (CLI) is a straightforward way to experiment with the Entropy network and explore common workflows."
aliases:
- "url"
- "cli"
---

{{< cards cols=2 >}}

{{< card
link="#interactive-cli"
title="Interactive CLI"
image="/images/entropy-tui-terminal.png"
subtitle="Use the text-based user interface (TUI) to interact with the CLI tool."
>}}

{{< card
link="#programmatic-cli"
title="Programmatic CLI"
image="/images/entropy-cli-terminal.png"
subtitle="Pass arguments directly to the CLI as single-line terminal commands."
>}}

{{< /cards >}}
{{< card
link="#interactive-cli"
title="Interactive CLI"
image="/images/entropy-tui-terminal.png"
subtitle="Use the text-based user interface (TUI) to interact with the CLI tool."
>}}

After installing, running `entropy` without any arguments will take you to the text-based user interface. If you pass any arguments, however, the CLI will assume you want to run the CLI as a single command.
{{< /cards >}}

## Install

Expand All @@ -49,31 +47,12 @@ Follow these steps to install Entropy globally using NPM:
npm install --global @entropyxyz/cli
```

1. You can now run the text-based interface anywhere using `entropy`:
1. You can now run the CLI from anywhere using `entropy`:

```shell
entropy
```

```output
? Select Action (Use arrow keys)
❯ Manage Accounts
Balance
Register
Sign
Transfer
Deploy Program
User Programs
Exit
```

1. You can also interact with the CLI through one-line commands by adding any of the arguments listed in the help section:

```shell
entropy --help
```

```output
Usage: entropy [options] [command]
Expand All @@ -100,119 +79,25 @@ Follow these steps to install Entropy globally using NPM:
a signature (string)
```

## Interactive CLI

The following functions are available within the CLI using the text-based user interface (TUI). To start the TUI, simply enter `entropy` without any arguments into your terminal:

### Manage Accounts

Create a new Entropy account to store locally. List all Entropy accounts stored locally. Import an account into the CLI using a seed.

```output
> Create/Import Account
Select Account
List Accounts
```

#### Create or Import Account

Create a new Entropy account or import an existing account using a seed.

#### Select Account

Select an account to use within other functions. This is relevant if you have multiple accounts.

For example, assume you have three accounts, and you want to check the balance of `account 2`. You would:
1. You can also interact with the CLI through the TUI by adding `tui`:

1. Start the CLI.
1. Navigate to **Manage Accounts**.
1. Navigate to **Select Account**.
1. Choose the account that you would like to select and use within other functions:

```output
? Choose account: (Use arrow keys)
> Gael (5CrFp9txcb5UECpNKsD6DTBsG4cj1z58DA43YikSVeeJqXJR)
Argo (5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv)
Lapp (5G92hBs4UfZpVFYtBmmN3UqPTzGgotq7PSA3XfBMALfvWDUb)
```shell
entropy tui
```

1. The account you select is what the CLI will use when running other functions.

#### List Accounts

Show all the locally stored accounts. This function shows secret details such as `seed` in plaintext.

### Balance

Get the balance of an account. You can select any of the accounts stored locally or enter an Entropy address.

```output
? Select Action Balance
Address 5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv has a balance of: 382000000000000 bits
? Return to main menu? (Y/n)
```

### Register

Register a locally stored account with the Entropy network.

```output
Attempting to register the address: 5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv
Your address 5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv has been successfully registered.
```

The selected account must have available funds. Each registration costs about `400000000` bits.

### Transfer

Transfer funds from a locally stored account to any other valid Entropy address.

```output
? Select Action Transfer
? Input amount to transfer: 12345
? Input recipient's address: 5G92hBs4UfZpVFYtBmmN3UqPTzGgotq7PSA3XfBMALfvWDUb
Transferring Funds |++++___________________| 22%
```
The `amount to transfer` value is in whole units, not bits. So transferring `1` would equal `10000000000` bits.
### Sign
Sign a message using a registered account.
```output
? Choose account: (Use arrow keys)
aragon (5FTwtSAjnKFybzkAKvyEo7owikXcHXmwzN7MzjwDNKEbjkub)
> charlie (5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT)
Other
```
### Deploy Program
Deploy a program from a locally stored account.
```output
? Select Action Deploy Program
? Select your action: (Use arrow keys)
> Deploy
Get Program Pointers
Exit
```
### User Programs
View all programs deployed to the network from locally stored accounts.
```output
? Select Action (Use arrow keys)
```output
? Select Action User Programs
? What would you like to do? (Use arrow keys)
> View My Programs
Add a Program to My List
Remove a Program from My List
Check if Program Exists
Exit to Main Menu
```
❯ Manage Accounts
Balance
Register
Sign
Transfer
Deploy Program
User Programs
Exit
```

## Programmatic CLI

Expand Down Expand Up @@ -360,6 +245,137 @@ Sign a message using the Entropy network. Output is a signature as a string.
entropy sign '5DSUAf2DwxW2ebZq15Pm6Z3SJ69Ur8fGd8ytWvgxvNjYtr7c' 'Pickle Pee, Pump-a-Rum!'
```

## Text-based user interface

The following functions are available within the CLI using the text-based user interface (TUI). To start the TUI, simply enter `entropy tui` without any arguments into your terminal:

```shell
entropy tui
```

```output
? Select Action (Use arrow keys)
❯ Manage Accounts
Balance
Register
Sign
Transfer
Deploy Program
User Programs
Exit
```

### Manage Accounts

Create a new Entropy account to store locally. List all Entropy accounts stored locally. Import an account into the CLI using a seed.

```output
> Create/Import Account
Select Account
List Accounts
```

#### Create or Import Account

Create a new Entropy account or import an existing account using a seed.

#### Select Account

Select an account to use within other functions. This is relevant if you have multiple accounts.

For example, assume you have three accounts, and you want to check the balance of `account 2`. You would:

1. Start the CLI.
1. Navigate to **Manage Accounts**.
1. Navigate to **Select Account**.
1. Choose the account that you would like to select and use within other functions:

```output
? Choose account: (Use arrow keys)
> Gael (5CrFp9txcb5UECpNKsD6DTBsG4cj1z58DA43YikSVeeJqXJR)
Argo (5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv)
Lapp (5G92hBs4UfZpVFYtBmmN3UqPTzGgotq7PSA3XfBMALfvWDUb)
```

1. The account you select is what the CLI will use when running other functions.

#### List Accounts

Show all the locally stored accounts. This function shows secret details such as `seed` in plaintext.

### Balance

Get the balance of an account. You can select any of the accounts stored locally or enter an Entropy address.

```output
? Select Action Balance
Address 5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv has a balance of: 382000000000000 bits
? Return to main menu? (Y/n)
```

### Register

Register a locally stored account with the Entropy network.

```output
Attempting to register the address: 5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv
Your address 5Dcps2RdXPQfiJBxxDnrF8iDzDHcnZC8rb5mcJ3xicqzhYbv has been successfully registered.
```

The selected account must have available funds. Each registration costs about `400000000` bits.

### Transfer

Transfer funds from a locally stored account to any other valid Entropy address.

```output
? Select Action Transfer
? Input amount to transfer: 12345
? Input recipient's address: 5G92hBs4UfZpVFYtBmmN3UqPTzGgotq7PSA3XfBMALfvWDUb
Transferring Funds |++++___________________| 22%
```
The `amount to transfer` value is in whole units, not bits. So transferring `1` would equal `10000000000` bits.
### Sign
Sign a message using a registered account.
```output
? Choose account: (Use arrow keys)
aragon (5FTwtSAjnKFybzkAKvyEo7owikXcHXmwzN7MzjwDNKEbjkub)
> charlie (5Ck5SLSHYac6WFt5UZRSsdJjwmpSZq85fd5TRNAdZQVzEAPT)
Other
```
### Deploy Program
Deploy a program from a locally stored account.
```output
? Select Action Deploy Program
? Select your action: (Use arrow keys)
> Deploy
Get Program Pointers
Exit
```
### User Programs
View all programs deployed to the network from locally stored accounts.
```output
? Select Action User Programs
? What would you like to do? (Use arrow keys)
> View My Programs
Add a Program to My List
Remove a Program from My List
Check if Program Exists
Exit to Main Menu
```
## Configuration
The CLI uses a configuration file to set and store basic information. This CLI uses [env-paths](https://www.npmjs.com/package/env-paths) to determine where configurations files should be stored:
Expand Down

0 comments on commit 60b2569

Please sign in to comment.