Skip to content

Commit

Permalink
fix: ignore empty string env vars when we parse CLI flags (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehuntsman authored Apr 28, 2023
1 parent c2f36c3 commit 7979b59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/lassie/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ var fetchCmd = &cli.Command{
DefaultText: "Providers will be discovered automatically",
Usage: "Addresses of providers, including peer IDs, to use instead of automatic discovery, seperated by a comma. All protocols will be attempted when connecting to these providers. Example: /ip4/1.2.3.4/tcp/1234/p2p/12D3KooWBSTEYMLSu5FnQjshEVah9LFGEZoQt26eacCEVYfedWA4",
Action: func(cctx *cli.Context, v string) error {
// Do nothing if given an empty string
if v == "" {
return nil
}

var err error
fetchProviderAddrInfos, err = types.ParseProviderStrings(v)
return err
Expand Down
10 changes: 10 additions & 0 deletions cmd/lassie/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ var FlagExcludeProviders = &cli.StringFlag{
Usage: "Provider peer IDs, seperated by a comma. Example: 12D3KooWBSTEYMLSu5FnQjshEVah9LFGEZoQt26eacCEVYfedWA4",
EnvVars: []string{"LASSIE_EXCLUDE_PROVIDERS"},
Action: func(cctx *cli.Context, v string) error {
// Do nothing if given an empty string
if v == "" {
return nil
}

providerBlockList = make(map[peer.ID]bool)
vs := strings.Split(v, ",")
for _, v := range vs {
Expand All @@ -117,6 +122,11 @@ var FlagProtocols = &cli.StringFlag{
Usage: "List of retrieval protocols to use, seperated by a comma",
EnvVars: []string{"LASSIE_SUPPORTED_PROTOCOLS"},
Action: func(cctx *cli.Context, v string) error {
// Do nothing if given an empty string
if v == "" {
return nil
}

var err error
protocols, err = types.ParseProtocolsString(v)
return err
Expand Down

0 comments on commit 7979b59

Please sign in to comment.