Skip to content

Commit e385bb8

Browse files
committed
Address more comments
1 parent 2587e90 commit e385bb8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

internal/file/file.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
package file
1616

1717
import (
18+
"bytes"
1819
"encoding/json"
1920
"fmt"
2021
"path/filepath"
2122

23+
"github.com/mongodb/mongocli/internal/config"
2224
"github.com/mongodb/mongocli/internal/search"
25+
"github.com/mongodb/mongocli/internal/version"
2326
"github.com/spf13/afero"
2427
"gopkg.in/yaml.v2"
2528
)
@@ -101,3 +104,22 @@ func Save(fs afero.Fs, filePath string, data interface{}) error {
101104

102105
return afero.WriteFile(fs, filePath, content, filePermission)
103106
}
107+
108+
func Path(tool, fileName string) (string, error) {
109+
var path bytes.Buffer
110+
var home string
111+
var err error
112+
113+
if tool == version.AtlasCLI {
114+
home, err = config.AtlasCLIConfigHome()
115+
} else {
116+
home, err = config.MongoCLIConfigHome()
117+
}
118+
if err != nil {
119+
return "", err
120+
}
121+
122+
path.WriteString(home)
123+
path.WriteString(fileName)
124+
return path.String(), nil
125+
}

0 commit comments

Comments
 (0)