-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
331 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,54 @@ | ||
package node | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/algorandfoundation/algorun-tui/internal/algod" | ||
"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/log" | ||
"github.com/spf13/cobra" | ||
"os/exec" | ||
) | ||
|
||
type DebugInfo struct { | ||
InPath bool `json:"inPath"` | ||
IsRunning bool `json:"isRunning"` | ||
IsService bool `json:"isService"` | ||
IsInstalled bool `json:"isInstalled"` | ||
Algod string `json:"algod"` | ||
Data []string `json:"data"` | ||
} | ||
|
||
var debugCmd = &cobra.Command{ | ||
Use: "debug", | ||
Short: "Display debug information for developers", | ||
Long: "Prints debug data to be copy and pasted to a bug report.", | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
log.Info("Collecting debug information...") | ||
|
||
// Warn user for prompt | ||
log.Warn(style.Yellow.Render(SudoWarningMsg)) | ||
|
||
paths := utils.GetKnownDataPaths() | ||
fmt.Printf("Algod in PATH: %v\n", system.CmdExists("algod")) | ||
fmt.Printf("Algod is installed: %v\n", algod.IsInstalled()) | ||
fmt.Printf("Algod is running: %v\n", algod.IsRunning()) | ||
fmt.Printf("Algod is service: %v\n", algod.IsService()) | ||
fmt.Printf("Algod paths: %+v\n", paths) | ||
path, _ := exec.LookPath("algod") | ||
info := DebugInfo{ | ||
InPath: system.CmdExists("algod"), | ||
IsRunning: algod.IsRunning(), | ||
IsService: algod.IsService(), | ||
IsInstalled: algod.IsInstalled(), | ||
Algod: path, | ||
Data: paths, | ||
} | ||
data, err := json.MarshalIndent(info, "", " ") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Info(style.Blue.Render("Copy and paste the following to a bug report:")) | ||
fmt.Println(style.Bold(string(data))) | ||
return nil | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
package node | ||
|
||
import ( | ||
"fmt" | ||
"github.com/algorandfoundation/algorun-tui/internal/algod" | ||
"github.com/algorandfoundation/algorun-tui/ui/style" | ||
"github.com/charmbracelet/log" | ||
"github.com/spf13/cobra" | ||
"os" | ||
) | ||
|
||
const InstallMsg = "Installing Algorand" | ||
const InstallExistsMsg = "algod is already installed" | ||
|
||
var installCmd = &cobra.Command{ | ||
Use: "install", | ||
Short: "Install Algorand node (Algod)", | ||
Long: "Install Algorand node (Algod) and other binaries on your system", | ||
Short: "Install the algorand daemon", | ||
Long: style.Purple(style.BANNER) + "\n" + style.LightBlue("Install the algorand daemon on your local machine"), | ||
SilenceUsage: true, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
fmt.Println("Checking if Algod is installed...") | ||
if algod.IsInstalled() { | ||
return fmt.Errorf(InstallExistsMsg) | ||
Run: func(cmd *cobra.Command, args []string) { | ||
// TODO: yes flag | ||
|
||
// TODO: get expected version | ||
log.Info(style.Green.Render(InstallMsg + " vX.X.X")) | ||
// Warn user for prompt | ||
log.Warn(style.Yellow.Render(SudoWarningMsg)) | ||
|
||
// TODO: compare expected version to existing version | ||
if algod.IsInstalled() && !force { | ||
log.Error(InstallExistsMsg) | ||
os.Exit(1) | ||
} | ||
|
||
// Run the installation | ||
err := algod.Install() | ||
if err != nil { | ||
log.Error(err) | ||
os.Exit(1) | ||
} | ||
return algod.Install() | ||
log.Info(style.Green.Render("Algorand installed successfully 🎉")) | ||
}, | ||
} | ||
|
||
func init() { | ||
installCmd.Flags().BoolVarP(&force, "force", "f", false, style.Yellow.Render("forcefully install the node")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.