Skip to content

Commit 2f31186

Browse files
committed
fix(man): Error handling gone wrong
1 parent 3d36bff commit 2f31186

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cmd/uniget/manpages.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import (
1212
myos "gitlab.com/uniget-org/cli/pkg/os"
1313
)
1414

15-
var manDirectory string
15+
var manDirectory string = "share/man"
1616

1717
func initManpagesCmd() {
18-
manpagesCmd.Flags().StringVar(&manDirectory, "path", "share/man", "Path to store manpages in (relative paths resolves using target directory)")
18+
manpagesCmd.Flags().StringVar(&manDirectory, "path", manDirectory, "Path to store manpages in (relative paths resolves using target directory)")
1919

2020
rootCmd.AddCommand(manpagesCmd)
2121
}
@@ -32,7 +32,7 @@ var manpagesCmd = &cobra.Command{
3232
Args: cobra.NoArgs,
3333
RunE: func(cmd *cobra.Command, args []string) (err error) {
3434
if (manDirectory[0:1] != "/") && (manDirectory[0:1] != ".") {
35-
manDirectory = fmt.Sprintf("%s/%s", "/"+configuration.Target, manDirectory)
35+
manDirectory = fmt.Sprintf("%s/%s", configuration.Prefix+"/"+configuration.Target, manDirectory)
3636
}
3737
logging.Debugf("Using base directory for manpages: %s", manDirectory)
3838

@@ -91,5 +91,8 @@ func writeManpage(cobraCmd *cobra.Command, name string, manDirectory string) err
9191
}()
9292

9393
_, err = file.WriteString(manPage.Build(roff.NewDocument()))
94-
return fmt.Errorf("failed to write manpage: %w", err)
94+
if err != nil {
95+
return fmt.Errorf("failed to write manpage: %w", err)
96+
}
97+
return nil
9598
}

0 commit comments

Comments
 (0)