Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Jul 15, 2024
1 parent 4945a26 commit bc398ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 30 deletions.
4 changes: 3 additions & 1 deletion cli/generate_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"github.com/spf13/cobra/doc"
)

var isDocsBuild = true
const DispatchCmdLong = "This is the main command for Dispatch CLI. Add a subcommand to make it useful."

const RunExampleText = "```\ndispatch run [options] -- <command>\n```"

func generateDocs(cmd *cobra.Command, title string) {
cmd.DisableAutoGenTag = true
Expand Down
11 changes: 10 additions & 1 deletion cli/generate_docs_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ package cli

import "github.com/spf13/cobra"

var isDocsBuild = false
const DispatchCmdLong = `Welcome to Dispatch!
To get started, use the login command to authenticate with Dispatch or create an account.
Documentation: https://docs.dispatch.run
Discord: https://dispatch.run/discord
Support: [email protected]
`

const RunExampleText = " dispatch run [options] -- <command>"

func generateDocs(_ *cobra.Command, _ string) {
// do nothing if the build tag "docs" is not set
Expand Down
20 changes: 1 addition & 19 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,11 @@ import (
"github.com/spf13/cobra"
)

var (
DispatchCmdLong = `Welcome to Dispatch!
To get started, use the login command to authenticate with Dispatch or create an account.
Documentation: https://docs.dispatch.run
Discord: https://dispatch.run/discord
Support: [email protected]
`
)

var mainCommandText string

func createMainCommand() *cobra.Command {
if isDocsBuild {
mainCommandText = "This is the main command for Dispatch CLI. Add a subcommand to make it useful."
} else {
mainCommandText = DispatchCmdLong
}
cmd := &cobra.Command{
Version: version(),
Use: "dispatch",
Long: mainCommandText,
Long: DispatchCmdLong,
Short: "Main command for Dispatch CLI",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
return loadEnvFromFile(DotEnvFilePath)
Expand Down
10 changes: 1 addition & 9 deletions cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,7 @@ var (
logPrefixSeparatorStyle = lipgloss.NewStyle().Foreground(grayColor)
)

var runExampleText string

func runCommand() *cobra.Command {
if isDocsBuild {
runExampleText = "```\ndispatch run [options] -- <command>\n```"
} else {
runExampleText = " dispatch run [options] -- <command>"
}

cmd := &cobra.Command{
Use: "run",
Short: "Run a Dispatch application",
Expand All @@ -73,7 +65,7 @@ func runCommand() *cobra.Command {
The command to start the local application endpoint should be
specified after the run command and its options:
`+runExampleText+`
`+RunExampleText+`
Dispatch spawns the local application endpoint and then dispatches
function calls to it continuously.
Expand Down

0 comments on commit bc398ae

Please sign in to comment.