Skip to content

Commit

Permalink
feat: implement utility and social commands using builder pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 committed Dec 1, 2023
1 parent 600bd69 commit 79a0eff
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cmd

import (
"os"

"github.com/hugobyte/dive-core/cli/cmd/social"
"github.com/hugobyte/dive-core/cli/cmd/utility"
"github.com/hugobyte/dive-core/cli/common"
"github.com/hugobyte/dive-core/cli/styles"
"github.com/spf13/cobra"
)

var rootCmd = common.NewDiveCommandBuilder().
SetUse("dive").
SetShort("Deployable Infrastructure for Virtually Effortless blockchain integration").
ToggleHelpCommand(true).
AddCommand(utility.CleanCmd).
AddCommand(utility.TutorialCmd).
AddCommand(utility.VersionCmd).
AddCommand(social.DiscordCmd).
AddCommand(social.TwitterCmd).
AddBoolPersistentFlag(&common.DiveLogs, "verbose", false, "Prints out logs to Stdout").
SetRunE(run).
Build()

func run(cmd *cobra.Command, args []string) error {
styles.RenderBanner()
cmd.Help()

return nil
}

func init() {
common.GetDiveContext()
}

func Execute() {
err := rootCmd.Execute()

if err != nil {
os.Exit(1)
}
}
16 changes: 16 additions & 0 deletions cli/cmd/social/discord.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package social

import (
"github.com/hugobyte/dive-core/cli/common"
"github.com/spf13/cobra"
)

const diveURL = "https://discord.gg/GyRQSBN3Cu"

var DiscordCmd = common.NewDiveCommandBuilder().
SetUse("discord").
SetShort("Opens DIVE discord channel").
SetLong(`The command opens the Discord channel for DIVE, providing a direct link or launching the Discord application to access the dedicated DIVE community. It allows users to engage in discussions, seek support, share insights, and collaborate with other members of the DIVE community within the Discord platform.`).
SetRun(discord).Build()

func discord(cmd *cobra.Command, args []string) {}
19 changes: 19 additions & 0 deletions cli/cmd/social/twitter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package social

import (
"github.com/hugobyte/dive-core/cli/common"
"github.com/spf13/cobra"
)

const twitterURL = "https://twitter.com/hugobyte"

var TwitterCmd = common.NewDiveCommandBuilder().
SetUse("twitter").
SetShort("Opens official HugoByte twitter home page").
SetLong(`The command opens the official HugoByte Twitter homepage. It launches a web browser and directs users to the designated Twitter profile of HugoByte, providing access to the latest updates, announcements, news, and insights
shared by the official HugoByte Twitter account. Users can stay informed about HugoByte's activities, engage with the
community, and follow our social media presence directly from the Twitter homepage.`,
).
SetRun(twitter).Build()

func twitter(cmd *cobra.Command, args []string) {}
15 changes: 15 additions & 0 deletions cli/cmd/utility/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package utility

import (
"github.com/hugobyte/dive-core/cli/common"
"github.com/spf13/cobra"
)

var CleanCmd = common.NewDiveCommandBuilder().
SetUse("clean").
SetShort("Cleans up Kurtosis leftover artifacts").
SetLong("Destroys and removes any running encalves. If no enclaves running to remove it will throw an error").
SetRun(clean).Build()

func clean(cmd *cobra.Command, args []string) {
}
23 changes: 23 additions & 0 deletions cli/cmd/utility/tutorial.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package utility

import (
"github.com/hugobyte/dive-core/cli/common"
"github.com/spf13/cobra"
)

const tutorialURL = "https://www.youtube.com/playlist?list=PL5Xd9z-fRL1vKtRlOzIlkhROspSSDeGyG"

var TutorialCmd = common.NewDiveCommandBuilder().
SetUse("tutorial").
SetShort("Opens DIVE Tutorial Youtube Playlist").
SetLong(
`The command opens the YouTube playlist containing DIVE tutorials. It launches a web browser or the YouTube application,
directing users to a curated collection of tutorial videos specifically designed to guide and educate users about DIVE. The playlist
offers step-by-step instructions, tips, and demonstrations to help users better understand and utilize the features and functionalities of DIVE.`,
).
SetRun(tutorial).
Build()

func tutorial(cmd *cobra.Command, args []string) {

}
15 changes: 15 additions & 0 deletions cli/cmd/utility/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package utility

import (
"github.com/hugobyte/dive-core/cli/common"
"github.com/spf13/cobra"
)

var VersionCmd = common.NewDiveCommandBuilder().
SetUse("version").
SetShort("Checks The DIVE CLI Version").
SetLong("Checks the current DIVE CLI version and warns if you are using an old version.").
SetRun(version).
Build()

func version(cmd *cobra.Command, args []string) {}

0 comments on commit 79a0eff

Please sign in to comment.