Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: beautify commands #57

Merged
merged 12 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 33 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,120 +1,50 @@
# ⌨️ AlgoRun-TUI
## algorun

<div align="center">
<img alt="Terminal Render" src="/assets/Banner.gif" width="65%">
</div>
Manage Algorand nodes from the command line

<div align="center">
<a target="_blank" href="https://github.com/algorandfoundation/algorun-tui/actions/workflows/test.yaml">
<img alt="CI Badge" src="https://github.com/algorandfoundation/algorun-tui/actions/workflows/test.yaml/badge.svg"/>
</a>
<a target="_blank" href="https://github.com/algorandfoundation/algorun-tui">
<img alt="CD Badge" src="https://img.shields.io/badge/CD-TODO-red"/>
</a>
<a target="_blank" href="https://github.com/algorandfoundation/algorun-tui/stargazers">
<img alt="Repository Stars Badge" src="https://img.shields.io/github/stars/algorandfoundation/algorun-tui?color=7B1E7A&logo=star&style=flat" />
</a>
<img alt="Repository Visitors Badge" src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Falgorandfoundation%2Falgorun-tui&countColor=%237B1E7A&style=flat" />
</div>
### Synopsis

---

<img alt="Terminal Render" src="/assets/nodekit.png" width="65%">


Manage Algorand nodes from the command line

Overview:
Welcome to Algorun, a terminal user interface for managing Algorand nodes.
This is your one stop shop for managing Algorand nodes, including node creation, configuration, and management.

Note: This is still a work in progress. Expect bugs and rough edges.

Terminal UI for managing Algorand nodes.
Built with [bubbles](https://github.com/charmbracelet/bubbles) & [bubbletea](https://github.com/charmbracelet/bubbletea)

> [!CAUTION]
> This project is in alpha state and under heavy development. We do not recommend performing actions (e.g. key management) on participation nodes connected to public networks.

# 🚀 Get Started

Download the latest release by running

```bash
curl -fsSL https://raw.githubusercontent.com/algorandfoundation/algorun-tui/refs/heads/main/install.sh | bash
```

Launch the TUI by replacing the `<ENDPOINT>` and `<TOKEN>`
with your server in the following example

> [!IMPORTANT]
> TUI requires the *admin* token in order to access participation key information. This can be found in the `algod.admin.token` file, e.g. `/var/lib/algorand/algod.admin.token`

```bash
./algorun --algod-endpoint <ENDPOINT> --algod-token <TOKEN>
algorun [flags]
```

# ℹ️ Advanced Usage

## 🧑‍💻 Commands

The default command will launch the full TUI application
### Options

```bash
./algorun
```

### Status

Render only the status overview in the terminal

```bash
./algorun status
-d, --datadir string Data directory for the node
-h, --help help for algorun
```

### Help

Display the usage information for the command
### SEE ALSO

```bash
./algorun help
```
## ⚙️ Configuration

Configuration precedence takes place in the following order:
* [algorun bootstrap](/man/algorun_bootstrap.md) - Initialize a fresh node
* [algorun catchup](/man/algorun_catchup.md) - Manage Fast-Catchup for your node
* [algorun configure](/man/algorun_configure.md) - Change settings on the system (WIP)
* [algorun debug](/man/algorun_debug.md) - Display debugging information
* [algorun install](/man/algorun_install.md) - Install the node daemon
* [algorun start](/man/algorun_start.md) - Start the node daemon
* [algorun stop](/man/algorun_stop.md) - Stop the node daemon
* [algorun uninstall](/man/algorun_uninstall.md) - Uninstall the node daemon
* [algorun upgrade](/man/algorun_upgrade.md) - Upgrade the node daemon

1. [ALGORAND_DATA Parsing](#algorand_data)
2. [Configuration File](#configuration-file)
3. [Environment Variables](#environment-variables)
4. [Command Line Flag Arguments](#flags)
###### Auto generated by spf13/cobra on 6-Jan-2025

### Flags
### Installing

The application supports the `algod-endpoint` and `algod-token` flags for configuration.
Connect to your server and run the installation script which will bootstrap your node.

```bash
./algorun --algod-endpoint http://localhost:8080 --algod-token aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

### Configuration File

The configuration file is named `.algorun.yaml` and is loaded in the following order:

1. Current Directory
2. Home Directory
3. /etc/algorun/

Example `.algorun.yaml` configuration file:

```yaml
algod-endpoint: "http://localhost:8080"
algod-token: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
```

### Environment Variables

Environment variables can be set in order to override a configuration or ALGORAND_DATA setting
but cannot be used to override the command line arguments.

The following are the additional ENV variables the TUI supports

| Name | Example |
|------------------------|----------------------------------------------------------------------------------------|
| ALGORUN_ALGOD-ENDPOINT | ALGORUN_ALGOD-ENDPOINT="http://localhost:8080" |
| ALGORUN_ALGOD-TOKEN | ALGORUN_ALGOD-TOKEN="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" |

### ALGORAND_DATA

The TUI searches the environment for an `ALGORAND_DATA` variable.
It then loads the `algod-token` and `algod-endpoint` values from
the algod data directory.

curl -fsSL https://raw.githubusercontent.com/algorandfoundation/algorun-tui/refs/heads/main/install.sh | bash
```
Binary file removed assets/Banner.gif
Binary file not shown.
Binary file removed assets/TUI.png
Binary file not shown.
7 changes: 7 additions & 0 deletions assets/footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Installing

Connect to your server and run the installation script which will bootstrap your node.

```bash
curl -fsSL https://raw.githubusercontent.com/algorandfoundation/algorun-tui/refs/heads/main/install.sh | bash
```
Binary file added assets/nodekit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"time"
)

var bootstrapCmdShort = "Initialize a fresh node. Alias for install, catchup, and start."
// bootstrapCmdShort provides a brief description of the "bootstrap" command to initialize a fresh Algorand node.
var bootstrapCmdShort = "Initialize a fresh node"

// cmdLong provides a detailed description of the Fast-Catchup feature, explaining its purpose and expected sync durations.
// bootstrapCmdLong provides a detailed description of the "bootstrap" command, including its purpose and functionality.
var bootstrapCmdLong = lipgloss.JoinVertical(
lipgloss.Left,
style.BANNER,
Expand All @@ -41,8 +42,6 @@ var tutorial = `# Welcome!

This is the beginning of your adventure into running the an Algorand node!

Morbi mauris quam, ornare ac commodo et, posuere id sem. Nulla id condimentum mauris. In vehicula sit amet libero vitae interdum. Nullam ac massa in erat volutpat sodales. Integer imperdiet enim cursus, ullamcorper tortor vel, imperdiet diam. Maecenas viverra ex iaculis, vehicula ligula quis, cursus lorem. Mauris nec nunc feugiat tortor sollicitudin porta ac quis turpis. Nam auctor hendrerit metus et pharetra.

`

// bootstrapCmd defines the "debug" command used to display diagnostic information for developers, including debug data.
Expand Down
3 changes: 0 additions & 3 deletions cmd/catchup/catchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ var (
// defaultLag represents the default minimum catchup delay in milliseconds for the Fast Catchup process.
defaultLag int = 30_000

// force indicates whether to bypass certain checks or enforcement logic within a function or command execution flow.
force bool = false

// cmdLong provides a detailed description of the Fast-Catchup feature, explaining its purpose and expected sync durations.
cmdLong = lipgloss.JoinVertical(
lipgloss.Left,
Expand Down
3 changes: 3 additions & 0 deletions cmd/catchup/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ type DebugInfo struct {
Catchpoint `json:"catchpoint"`
}

// debugCmdShort provides a concise description for the debug command, indicating it displays debug information for Fast-Catchup.
var debugCmdShort = "Display debug information for Fast-Catchup."

// debugCmdLong provides a detailed description for the debug command, focusing on debugging fast-catchup issues.
var debugCmdLong = lipgloss.JoinVertical(
lipgloss.Left,
style.Purple(style.BANNER),
Expand Down
5 changes: 1 addition & 4 deletions cmd/catchup/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
)

// startCmdLong provides a detailed description and overview message for the 'start' command, including notes and caveats.
var startCmdLong = lipgloss.JoinVertical(
lipgloss.Left,
style.Purple(style.BANNER),
Expand Down Expand Up @@ -60,7 +61,3 @@ var startCmd = utils.WithAlgodFlags(&cobra.Command{
log.Info(style.Green.Render(res))
},
}, &dataDir)

func init() {
startCmd.Flags().BoolVarP(&force, "force", "f", false, style.Yellow.Render("forcefully catchup the node"))
}
7 changes: 3 additions & 4 deletions cmd/catchup/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
"github.com/spf13/cobra"
)

// stopCmdShort provides a concise description of the "stop" command.
var stopCmdShort = "Stop a fast catchup"

// stopCmdLong provides a detailed description for the "stop" command including its functionality and important notes.
var stopCmdLong = lipgloss.JoinVertical(
lipgloss.Left,
style.Purple(style.BANNER),
Expand Down Expand Up @@ -50,7 +53,3 @@ var stopCmd = utils.WithAlgodFlags(&cobra.Command{

},
}, &dataDir)

func init() {
stopCmd.Flags().BoolVarP(&force, "force", "f", false, style.Yellow.Render("forcefully catchup the node"))
}
5 changes: 4 additions & 1 deletion cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import (
"github.com/spf13/cobra"
)

var short = "Configure the Algorand daemon."
// short holds a brief description of the system settings configuration command, currently marked as work in progress.
var short = "Change settings on the system (WIP)"

// long combines styled strings and descriptions for the detailed command overview displayed in the CLI.
var long = lipgloss.JoinVertical(
lipgloss.Left,
style.Purple(style.BANNER),
Expand Down
5 changes: 5 additions & 0 deletions cmd/configure/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import (
"github.com/spf13/cobra"
)

// serviceShort provides a brief description of the service command, emphasizing its role in installing service files.
var serviceShort = "Install service files for the Algorand daemon."

// serviceLong provides a detailed description of the service command, its purpose, and an experimental warning note.
var serviceLong = lipgloss.JoinVertical(
lipgloss.Left,
style.Purple(style.BANNER),
Expand All @@ -22,6 +25,8 @@ var serviceLong = lipgloss.JoinVertical(
"",
style.Yellow.Render(explanations.ExperimentalWarning),
)

// serviceCmd is a Cobra command for managing Algorand service files, requiring root privileges to ensure proper execution.
var serviceCmd = &cobra.Command{
Use: "service",
Short: serviceShort,
Expand Down
21 changes: 19 additions & 2 deletions cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/algorandfoundation/algorun-tui/internal/algod/utils"
"github.com/algorandfoundation/algorun-tui/internal/system"
"github.com/algorandfoundation/algorun-tui/ui/style"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/log"
"github.com/spf13/cobra"
"os/exec"
Expand Down Expand Up @@ -36,11 +37,27 @@ type DebugInfo struct {
DataFolder utils.DataFolderConfig `json:"data"`
}

// debugCmdShort provides a brief description of the "debug" command, which displays debugging information.
var debugCmdShort = "Display debugging information"

// debugCmdLong provides a detailed description of the "debug" command, outlining its purpose and functionality.
var debugCmdLong = lipgloss.JoinVertical(
lipgloss.Left,
style.BANNER,
"",
style.Bold(debugCmdShort),
"",
style.BoldUnderline("Overview:"),
"Prints the known state of the nodekit",
"Checks various paths and configurations to present useful information for bug reports.",
"",
)

// debugCmd defines the "debug" command used to display diagnostic information for developers, including debug data.
var debugCmd = cmdutils.WithAlgodFlags(&cobra.Command{
Use: "debug",
Short: "Display debug information for developers",
Long: "Prints debug data to be copy and pasted to a bug report.",
Short: debugCmdShort,
Long: debugCmdLong,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
log.Info("Collecting debug information...")
Expand Down
18 changes: 14 additions & 4 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/algorandfoundation/algorun-tui/cmd/utils/explanations"
"github.com/algorandfoundation/algorun-tui/internal/algod"
"github.com/algorandfoundation/algorun-tui/ui/style"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/log"
"github.com/spf13/cobra"
"os"
Expand All @@ -16,15 +17,24 @@ const InstallMsg = "Installing Algorand"
// InstallExistsMsg is a constant string used to indicate that the Algod is already installed on the system.
const InstallExistsMsg = "algod is already installed"

var installShort = "Install the algorand daemon"
var installShort = "Install the node daemon"

var installLong = style.Purple(style.BANNER) + "\n" + style.LightBlue("Install the algorand daemon on your local machine")
var installLong = lipgloss.JoinVertical(
lipgloss.Left,
style.Purple(style.BANNER),
"",
style.Bold(installShort),
"",
style.BoldUnderline("Overview:"),
"Configures the local package manager and installs the algorand daemon on your local machine",
"",
)

// installCmd is a Cobra command that installs the Algorand daemon on the local machine, ensuring the service is operational.
var installCmd = &cobra.Command{
Use: "install",
Short: "Install the algorand daemon",
Long: style.Purple(style.BANNER) + "\n" + style.LightBlue("Install the algorand daemon on your local machine"),
Short: installShort,
Long: installLong,
SilenceUsage: true,
Run: func(cmd *cobra.Command, args []string) {
// TODO: yes flag
Expand Down
27 changes: 14 additions & 13 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

var (
Name = "algorun"

// algodEndpoint defines the URI address of the Algorand node, including the protocol (http/https), for client communication.
algodData string
Expand All @@ -42,9 +43,9 @@ var (
"",
style.Yellow.Render(explanations.ExperimentalWarning),
)
// rootCmd is the primary command for managing Algorand nodes, providing CLI functionality and TUI for interaction.
rootCmd = utils.WithAlgodFlags(&cobra.Command{
Use: "algorun",
// RootCmd is the primary command for managing Algorand nodes, providing CLI functionality and TUI for interaction.
RootCmd = utils.WithAlgodFlags(&cobra.Command{
Use: Name,
Version: Version,
Short: short,
Long: long,
Expand Down Expand Up @@ -129,19 +130,19 @@ func init() {
log.SetReportTimestamp(false)
// Add Commands
if runtime.GOOS != "windows" {
rootCmd.AddCommand(bootstrapCmd)
rootCmd.AddCommand(debugCmd)
rootCmd.AddCommand(installCmd)
rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(stopCmd)
rootCmd.AddCommand(uninstallCmd)
rootCmd.AddCommand(upgradeCmd)
rootCmd.AddCommand(catchup.Cmd)
rootCmd.AddCommand(configure.Cmd)
RootCmd.AddCommand(bootstrapCmd)
RootCmd.AddCommand(debugCmd)
RootCmd.AddCommand(installCmd)
RootCmd.AddCommand(startCmd)
RootCmd.AddCommand(stopCmd)
RootCmd.AddCommand(uninstallCmd)
RootCmd.AddCommand(upgradeCmd)
RootCmd.AddCommand(catchup.Cmd)
RootCmd.AddCommand(configure.Cmd)
}
}

// Execute executes the root command.
func Execute() error {
return rootCmd.Execute()
return RootCmd.Execute()
}
Loading
Loading