Skip to content

Commit

Permalink
feat: Default to printing help when arguments not provided (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
sindrel authored Aug 27, 2023
1 parent 9028d53 commit e325ac9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions cmd/gliffy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
},
Expand Down

0 comments on commit e325ac9

Please sign in to comment.