|
|
@ -6,7 +6,6 @@ import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"io/fs"
|
|
|
|
"io/fs"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"os/user"
|
|
|
|
|
|
|
|
"path/filepath"
|
|
|
|
"path/filepath"
|
|
|
|
"regexp"
|
|
|
|
"regexp"
|
|
|
|
"runtime"
|
|
|
|
"runtime"
|
|
|
@ -24,21 +23,10 @@ func runningOnWindows() bool {
|
|
|
|
|
|
|
|
|
|
|
|
// generateDefaultConfigs is used to generate a folder of default config files
|
|
|
|
// generateDefaultConfigs is used to generate a folder of default config files
|
|
|
|
// for common languages. These default config files are embedded into the program, and will
|
|
|
|
// for common languages. These default config files are embedded into the program, and will
|
|
|
|
// be outputted into a directory.
|
|
|
|
// be outputted into the given directory.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// If there is an error encountered, the error is returned.
|
|
|
|
// If there is an error encountered, the error is returned.
|
|
|
|
func generateDefaultConfigs() error {
|
|
|
|
func generateDefaultConfigs(configOutputPath string) error {
|
|
|
|
|
|
|
|
|
|
|
|
var configOutputPath string // Location of config files, depends on OS
|
|
|
|
|
|
|
|
if runningOnWindows() {
|
|
|
|
|
|
|
|
configOutputPath = "%APPDATA%\\ccat"
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
currentUser, err := user.Current()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
configOutputPath = filepath.Join("/home/" + currentUser.Username + "/.config/ccat/")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
err := os.MkdirAll(configOutputPath, 0755)
|
|
|
|
err := os.MkdirAll(configOutputPath, 0755)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if os.IsExist(err) {
|
|
|
|
if os.IsExist(err) {
|
|
|
|