Skip to content

Commit

Permalink
Add flag for config path
Browse files Browse the repository at this point in the history
  • Loading branch information
hjr265 committed Jan 12, 2023
1 parent 1b193af commit 1a90176
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
go.work

/printd
/config.toml
/printd-config.toml
/*.pdf

dist/
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Config struct {
}

func parseConfig() (cfg Config, err error) {
b, err := os.ReadFile("config.toml")
b, err := os.ReadFile(flagConfig)
if err != nil {
return
}
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ package main

import (
"context"
"flag"
"log"
)

var (
flagConfig string
)

func main() {
flag.StringVar(&flagConfig, "config", "printd-config.toml", "path to configuration file")
flag.Parse()

log.SetFlags(0)

ctx := context.Background()
Expand Down

0 comments on commit 1a90176

Please sign in to comment.