Skip to content

Commit

Permalink
fix: loop exit issue & update flag aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
kha7iq committed Jul 7, 2021
1 parent 45ad8a6 commit f522a74
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
Expand All @@ -24,14 +24,16 @@ func main() {
app.Usage = "Substitute environment variables defined as go templates."
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "prefix, pr",
Name: "prefix",
Aliases: []string{"pr"},
Usage: "Match only variables with given prefix pattern",
Destination: &helpers.GlobalOpts.Prefix,
EnvVars: []string{"SUBVARS_PREFIX"},
},
&cli.StringFlag{
Destination: &helpers.GlobalOpts.MissingKey,
Name: "missingkey",
Aliases: []string{"m"},
Usage: "Behavior for missing key when parsing variables." +
"Available options 'invalid', 'error' or 'zero'",
EnvVars: []string{"SUBVARS_MISSINGKEY"},
Expand All @@ -42,12 +44,12 @@ func main() {
app.Action = func(c *cli.Context) error {
b, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return errors.New("unable to read input")
return fmt.Errorf("unable to read input \nERROR: %v\n", err)
}

t, err := helpers.ParseString(string(b))
if err != nil {
return errors.New("error parsing string stream")
return fmt.Errorf("unable to parse string stream \nERROR: %v\n", err)
}

if len(helpers.GlobalOpts.Prefix) != 0 {
Expand Down

0 comments on commit f522a74

Please sign in to comment.