Skip to content

Commit

Permalink
modularised common cmd tree - DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
supragya committed Jan 9, 2021
1 parent 88ee8d3 commit 9e2fa74
Show file tree
Hide file tree
Showing 5 changed files with 739 additions and 11 deletions.
1 change: 0 additions & 1 deletion cmd/relay/eth/actions/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ var CreateCmd = &cobra.Command{
runtimeArgs["Name"] = raName
runtimeArgs["AbciVersion"] = raAbciVersion
runtimeArgs["SyncMode"] = raSyncMode

}
var projectConfig types.Project
err := viper.UnmarshalKey(cmn.ProjectID, &projectConfig)
Expand Down
38 changes: 28 additions & 10 deletions cmd/relay/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ limitations under the License.
package eth

import (
"github.com/marlinprotocol/ctl2/cmd/relay/eth/actions"
"github.com/marlinprotocol/ctl2/cmd/relay/eth/config"
// "github.com/marlinprotocol/ctl2/cmd/relay/eth/actions"
// "github.com/marlinprotocol/ctl2/cmd/relay/eth/config"
"os"

"github.com/marlinprotocol/ctl2/modules/appcommands"
projectRunners "github.com/marlinprotocol/ctl2/modules/runner/relay_eth"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand All @@ -29,12 +34,25 @@ var EthCmd = &cobra.Command{
}

func init() {
EthCmd.AddCommand(actions.CreateCmd)
EthCmd.AddCommand(actions.RestartCmd)
EthCmd.AddCommand(actions.RecreateCmd)
EthCmd.AddCommand(actions.StatusCmd)
EthCmd.AddCommand(actions.DestroyCmd)
EthCmd.AddCommand(actions.VersionsCmd)
EthCmd.AddCommand(actions.LogsCmd)
EthCmd.AddCommand(config.ConfigCmd)
app, err := appcommands.GetNewApp("relay_eth", projectRunners.GetRunnerInstance,
appcommands.CommandDetails{Use: "create", DescShort: "Create relay for ethereum blockchain", DescLong: "Create relay for ethereum blockchain"},
appcommands.CommandDetails{Use: "destroy", DescShort: "Destroy relay for ethereum blockchain", DescLong: "Destroy relay for ethereum blockchain"},
appcommands.CommandDetails{Use: "logs", DescShort: "Tail logs for running relay (eth) instances", DescLong: "Tail logs for running relay (eth) instances"},
appcommands.CommandDetails{Use: "status", DescShort: "Show current status of currently running relay instances", DescLong: "Show current status of currently running relay instances"},
appcommands.CommandDetails{Use: "recreate", DescShort: "Recreate end to end relay (eth) instances", DescLong: "Recreate end to end relay (eth) instances"},
appcommands.CommandDetails{Use: "restart", DescShort: "Restart services for relay (eth) instances", DescLong: "Restart services for relay (eth) instances"},
appcommands.CommandDetails{Use: "versions", DescShort: "Show available versions for use", DescLong: "Show available versions for use"})
if err != nil {
log.Error("Error while creating relay_eth application command tree")
os.Exit(1)
}

EthCmd.AddCommand(app.CreateCmd.Cmd)
EthCmd.AddCommand(app.DestroyCmd.Cmd)
EthCmd.AddCommand(app.LogsCmd.Cmd)
EthCmd.AddCommand(app.StatusCmd.Cmd)
EthCmd.AddCommand(app.RecreateCmd.Cmd)
EthCmd.AddCommand(app.RestartCmd.Cmd)
EthCmd.AddCommand(app.VersionsCmd.Cmd)

}
Loading

0 comments on commit 9e2fa74

Please sign in to comment.