mirror of
https://github.com/spf13/cobra
synced 2024-11-24 14:47:12 +00:00
Use filepath.Join, not string math. Fixes #226.
This commit is contained in:
parent
9c93009019
commit
8e6aca4182
2 changed files with 6 additions and 4 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -46,8 +47,8 @@ func GenManTree(cmd *cobra.Command, header *GenManHeader, dir string) error {
|
||||||
}
|
}
|
||||||
needToResetTitle := header.Title == ""
|
needToResetTitle := header.Title == ""
|
||||||
|
|
||||||
filename := cmd.CommandPath()
|
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".1"
|
||||||
filename = dir + strings.Replace(filename, " ", "-", -1) + ".1"
|
filename := filepath.Join(dir, basename)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -156,8 +157,8 @@ func GenMarkdownTreeCustom(cmd *cobra.Command, dir string, filePrepender, linkHa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := cmd.CommandPath()
|
basename := strings.Replace(cmd.CommandPath(), " ", "_", -1) + ".md"
|
||||||
filename = dir + strings.Replace(filename, " ", "_", -1) + ".md"
|
filename := filepath.Join(dir, basename)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue