Skip to content

Commit

Permalink
chore: Ensure all errors are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed May 4, 2024
1 parent e4b7f8c commit d101a86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func run(cmd *cobra.Command, args []string) error {
return err
}

_, _ = io.WriteString(cmd.OutOrStdout(), conf.String())
return nil
_, err = io.WriteString(cmd.OutOrStdout(), conf.String())
return err
}

func buildVersion(version, commit string) string {
Expand Down
12 changes: 8 additions & 4 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ const (

func RegisterFlags(cmd *cobra.Command) {
cmd.Flags().String(ConfigFlag, "", `Config file (default ".changelog-generator.yaml")`)
_ = cmd.RegisterFlagCompletionFunc(ConfigFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
if err := cmd.RegisterFlagCompletionFunc(ConfigFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"yaml"}, cobra.ShellCompDirectiveFilterFileExt
})
}); err != nil {
panic(err)
}

cmd.Flags().String(RepoFlag, ".", `Path to the git repo root. Parent directories will be walked until .git is found.`)
_ = cmd.RegisterFlagCompletionFunc(RepoFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
if err := cmd.RegisterFlagCompletionFunc(RepoFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{}, cobra.ShellCompDirectiveFilterDirs
})
}); err != nil {
panic(err)
}

cmd.Flags().String(CompletionFlag, "", "Output command-line completion code for the specified shell. Can be 'bash', 'zsh', 'fish', or 'powershell'.")
if err := cmd.RegisterFlagCompletionFunc(CompletionFlag, func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
Expand Down

0 comments on commit d101a86

Please sign in to comment.