Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
dogancanbakir committed Aug 3, 2023
1 parent ecd7d12 commit 5d6cda1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/proxify/proxify.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import (

func main() {

options := runner.ParseOptions()
options, err := runner.ParseOptions()
if err != nil {
gologger.Fatal().Msgf("Could not parse options: %s\n", err)
}

proxifyRunner, err := runner.NewRunner(options)
if err != nil {
Expand Down
11 changes: 7 additions & 4 deletions internal/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Options struct {
OutputJsonl bool // OutputJsonl outputs data in JSONL format
}

func ParseOptions() *Options {
func ParseOptions() (*Options, error) {
options := &Options{}

flagSet := goflags.NewFlagSet()
Expand Down Expand Up @@ -119,14 +119,17 @@ func ParseOptions() *Options {
flagSet.BoolVarP(&veryVerbose, "very-verbose", "vv", false, "Very Verbose"),
)

_ = flagSet.Parse()
if err := flagSet.Parse(); err != nil {
return nil, err
}

if options.Directory != "" {
_ = os.MkdirAll(options.Directory, os.ModePerm)
readFlagsConfig(flagSet, options.Directory)
} else {
homeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
return nil, err
}
options.Directory = filepath.Join(homeDir, ".config", "proxify")
}
Expand Down Expand Up @@ -154,7 +157,7 @@ func ParseOptions() *Options {
}
}

return options
return options, nil
}

// readFlagsConfig reads the config file from the default config dir and copies it to the current config dir.
Expand Down

0 comments on commit 5d6cda1

Please sign in to comment.