From bc398aeea56c91eae164c7e588850991f16a2159 Mon Sep 17 00:00:00 2001 From: Sergey Rubanov Date: Mon, 15 Jul 2024 23:35:58 +0200 Subject: [PATCH] cleanup --- cli/generate_docs.go | 4 +++- cli/generate_docs_default.go | 11 ++++++++++- cli/main.go | 20 +------------------- cli/run.go | 10 +--------- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/cli/generate_docs.go b/cli/generate_docs.go index 4450247..ca4a672 100644 --- a/cli/generate_docs.go +++ b/cli/generate_docs.go @@ -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] -- \n```" func generateDocs(cmd *cobra.Command, title string) { cmd.DisableAutoGenTag = true diff --git a/cli/generate_docs_default.go b/cli/generate_docs_default.go index d8b0722..3fe6860 100644 --- a/cli/generate_docs_default.go +++ b/cli/generate_docs_default.go @@ -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: support@dispatch.run +` + +const RunExampleText = " dispatch run [options] -- " func generateDocs(_ *cobra.Command, _ string) { // do nothing if the build tag "docs" is not set diff --git a/cli/main.go b/cli/main.go index 2d1e7ef..5bcdfbe 100644 --- a/cli/main.go +++ b/cli/main.go @@ -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: support@dispatch.run -` -) - -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) diff --git a/cli/run.go b/cli/run.go index 9ae1eb9..0fc8544 100644 --- a/cli/run.go +++ b/cli/run.go @@ -56,15 +56,7 @@ var ( logPrefixSeparatorStyle = lipgloss.NewStyle().Foreground(grayColor) ) -var runExampleText string - func runCommand() *cobra.Command { - if isDocsBuild { - runExampleText = "```\ndispatch run [options] -- \n```" - } else { - runExampleText = " dispatch run [options] -- " - } - cmd := &cobra.Command{ Use: "run", Short: "Run a Dispatch application", @@ -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.