diff --git a/justfile b/justfile index ef1f027..eaab8d5 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,6 @@ -# Builds all binarys + +# Builds all binaries for the /bin directory build-all: build-linux build-osx build-windows # Builds Linux executable @@ -12,4 +13,8 @@ build-windows: # Builds MacOS executable build-osx: - cd ./src && GOOS=darwin GOARCH=amd64 go build -o bin/gophrase-386-darwin main.go \ No newline at end of file + cd ./src && GOOS=darwin GOARCH=amd64 go build -o bin/gophrase-386-darwin main.go + +# Build local +build-local: + cd ./src && go build -o ../gophrase \ No newline at end of file diff --git a/src/bin/gophrase-386-darwin b/src/bin/gophrase-386-darwin index 41fcde6..8758e45 100755 Binary files a/src/bin/gophrase-386-darwin and b/src/bin/gophrase-386-darwin differ diff --git a/src/bin/gophrase-amd64-linux b/src/bin/gophrase-amd64-linux index e7f2ddc..d2e83fd 100755 Binary files a/src/bin/gophrase-amd64-linux and b/src/bin/gophrase-amd64-linux differ diff --git a/src/bin/gophrase-amd64.exe b/src/bin/gophrase-amd64.exe index b2048ff..5490f98 100755 Binary files a/src/bin/gophrase-amd64.exe and b/src/bin/gophrase-amd64.exe differ diff --git a/src/config/config.go b/src/config/config.go index 582d0ce..c2ef47b 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -6,17 +6,19 @@ import ( "gopkg.in/yaml.v3" "io/ioutil" "log" + "os" ) // Static asset constants const ( - EffLarge = "assets/wordlists/eff_large_wordlist.json" - EffShort1 = "assets/wordlists/eff_short_wordlist_1.json" - EffShort2 = "assets/wordlists/eff_short_wordlist_2.json" - Reinhold = "assets/wordlists/reinhold_wordlist.json" - Characters = "assets/wordlists/special_characters.json" - ListOptions = "assets/list_options.txt" - Configuration = "assets/config/config.yaml" + EffLarge = "assets/wordlists/eff_large_wordlist.json" + EffShort1 = "assets/wordlists/eff_short_wordlist_1.json" + EffShort2 = "assets/wordlists/eff_short_wordlist_2.json" + Reinhold = "assets/wordlists/reinhold_wordlist.json" + Characters = "assets/wordlists/special_characters.json" + ListOptions = "assets/list_options.txt" + DefaultConfiguration = "assets/config/config.yaml" + CustomConfiguration = "config.yaml" ) // Assets is the embed.FS file system to access embedded files throughout the application. @@ -41,12 +43,11 @@ func (c *Config) PrintConfig() { // SetConfig takes in a config and writes it to the configuration file. func SetConfig(config *Config) { - fileLocation := Configuration file, err := yaml.Marshal(config) if err != nil { log.Fatal(err) } - err = ioutil.WriteFile(fileLocation, file, 0644) + err = ioutil.WriteFile(CustomConfiguration, file, 0644) if err != nil { log.Fatal(err) } @@ -54,11 +55,19 @@ func SetConfig(config *Config) { // LoadConfig reads a configuration file and loads it into the LoadedConfig variable. func LoadConfig() { - fileLocation, err := Assets.ReadFile(Configuration) + customFileLocation, err := os.ReadFile(CustomConfiguration) + if customFileLocation != nil { + err = yaml.Unmarshal(customFileLocation, &LoadedConfig) + if err != nil { + log.Fatal(err) + } + return + } + defaultFileLocation, err := Assets.ReadFile(DefaultConfiguration) if err != nil { log.Fatal(err) } - err = yaml.Unmarshal(fileLocation, &LoadedConfig) + err = yaml.Unmarshal(defaultFileLocation, &LoadedConfig) if err != nil { log.Fatal(err) }