-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
18b3536
commit f5228f5
Showing
9 changed files
with
91 additions
and
84 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetRootCmd represents the base command when called without any subcommands | ||
func GetRootCmd(version string) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "dbctl", | ||
Version: version, | ||
Short: "Your swish knife of testing databases", | ||
Long: `Dbctl is a command line tools, providing simple | ||
command to run and manage databases for tests proposes`, | ||
} | ||
|
||
return cmd | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetStartCmd represents the start command | ||
func GetStartCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "start", | ||
Short: "Start a database instance", | ||
} | ||
|
||
cmd.PersistentFlags().BoolP("detach", "d", false, "Detached mode: Run database in the background") | ||
cmd.PersistentFlags().Bool("use-docker", true, "Use Docker to run databases") | ||
|
||
cmd.AddCommand(GetPgCmd()) | ||
return cmd | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// GetVersionCmd represents the version command | ||
func GetVersionCmd(version string) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "version", | ||
Short: "Show the dbctl version information", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Printf("dbctl version %s\n", version) | ||
}, | ||
} | ||
} |
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 |
---|---|---|
|
@@ -3,8 +3,23 @@ Copyright © 2022 Mohsen Mirzakhani <[email protected]> | |
*/ | ||
package main | ||
|
||
import "github.com/mirzakhany/dbctl/cmd" | ||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/mirzakhany/dbctl/internal/cmd" | ||
) | ||
|
||
// version will be populated by the build script with the sha of the last git commit. | ||
var version = "snapshot" | ||
|
||
func main() { | ||
cmd.Execute() | ||
root := cmd.GetRootCmd(version) | ||
root.SetVersionTemplate(fmt.Sprintf("dbctl version %s\n", version)) | ||
|
||
root.AddCommand(cmd.GetStartCmd()) | ||
|
||
if err := root.Execute(); err != nil { | ||
os.Exit(1) | ||
} | ||
} |