Skip to content

Commit

Permalink
feat: add cli args for snapKey and outDir
Browse files Browse the repository at this point in the history
  • Loading branch information
crebsy committed Jul 15, 2024
1 parent f11cd3f commit d33ee45
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,26 @@ var CHUNK_SIZE = 8192
var MAX_RETRIES = _getMaxRetries()

func main() {
fmt.Println(getBanner())

apiBaseUrl := os.Getenv("MOONSNAP_API_BASE_URL")
if len(apiBaseUrl) > 0 {
API_BASE_URL = apiBaseUrl
}
if len(SNAP_KEY) == 0 && len(os.Args) > 1 {
SNAP_KEY = os.Args[1]
}

fmt.Println(getBanner())
if len(API_BASE_URL) == 0 {
panic("Please provide a MOONSNAP_API_BASE_URL")
if len(OUT_DIR) == 0 && len(os.Args) > 2 {
OUT_DIR = os.Args[2]
} else {
OUT_DIR = "."
}

if len(SNAP_KEY) == 0 {
panic("Please provide a MOONSNAP_SNAP_KEY")
}

if len(OUT_DIR) == 0 {
OUT_DIR = "/tmp"
}

err := os.MkdirAll(OUT_DIR, 0755)
if err != nil {
panic(err)
Expand Down

0 comments on commit d33ee45

Please sign in to comment.