Skip to content

Commit

Permalink
fixup! feat(cli): Add add and list applications commands
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoura committed Jul 19, 2024
1 parent 8f9d255 commit 213981b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cmd/cartesi-rollups-cli/root/app/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package add

import (
"fmt"
"log/slog"
"os"

Expand Down Expand Up @@ -93,6 +94,10 @@ func init() {
func run(cmd *cobra.Command, args []string) {
ctx := cmd.Context()

if cmdcommom.Database == nil {
panic("Database was not initialized")
}

var applicationStatus model.ApplicationStatus
switch status {
case statusRunning:
Expand All @@ -115,4 +120,5 @@ func run(cmd *cobra.Command, args []string) {

err := cmdcommom.Database.InsertApplication(ctx, &application)
cobra.CheckErr(err)
fmt.Printf("Application %v successfully added\n", application.ContractAddress)
}
6 changes: 3 additions & 3 deletions cmd/cartesi-rollups-cli/root/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

var Cmd = &cobra.Command{
Use: "app",
Short: "Application management related commands",
PreRun: common.Setup,
Use: "app",
Short: "Application management related commands",
PersistentPreRun: common.Setup,
}

func init() {
Expand Down
4 changes: 4 additions & 0 deletions cmd/cartesi-rollups-cli/root/app/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ cartesi-rollups-cli app list`
func run(cmd *cobra.Command, args []string) {
ctx := cmd.Context()

if common.Database == nil {
panic("Database was not initialized")
}

applications, err := common.Database.GetAllApplications(ctx)
cobra.CheckErr(err)
for index, app := range applications {
Expand Down

0 comments on commit 213981b

Please sign in to comment.