From e325ac9d0f168f81701d3e38e3d9621133b337d1 Mon Sep 17 00:00:00 2001 From: Sindre Lindstad <35308882+sindrel@users.noreply.github.com> Date: Sun, 27 Aug 2023 14:04:11 +0200 Subject: [PATCH] feat: Default to printing help when arguments not provided (#21) --- cmd/gliffy.go | 14 ++++++++++++-- cmd/version.go | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmd/gliffy.go b/cmd/gliffy.go index 09524a2..e3f7504 100644 --- a/cmd/gliffy.go +++ b/cmd/gliffy.go @@ -16,13 +16,23 @@ var defaultOutputPath = "your_file.gliffy" var gliffyCmd = &cobra.Command{ Use: "gliffy", Short: "Convert an Excalidraw diagram to Gliffy format", - Long: `Use this command to convert an Excalidraw diagram to the Gliffy format.`, + Long: `This command is used to convert an Excalidraw diagram to the Gliffy format. + + When an output file path is not provided, it will be determined +automatically based on the filename of the input file. I.e. the +input file path './subfolder/your_file.excalidraw' will produce +the default output file path './your_file.gliffy'. + +Example: + exconv gliffy -i your_file.excalidraw +`, Run: func(cmd *cobra.Command, args []string) { importPath, _ := cmd.Flags().GetString("input") exportPath, _ := cmd.Flags().GetString("output") if len(importPath) == 0 { - fmt.Fprintf(os.Stderr, "Input file path not provided. (Use --help for details.)\n") + fmt.Fprintf(os.Stderr, "Error: Input file path not provided.\n\n") + cmd.Help() os.Exit(1) } diff --git a/cmd/version.go b/cmd/version.go index 4b461c6..715be90 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -14,7 +14,7 @@ var ( var versionCmd = &cobra.Command{ Use: "version", Short: "Output the application version", - Long: `Provides information about the release version and the Git commit it was built from.`, + Long: `This command provides information about the release version and the Git commit it was built from.`, Run: func(cmd *cobra.Command, args []string) { fmt.Printf("v%s (%s)\n", version, string(commit[0:7])) },