Skip to content

Commit

Permalink
Output format reads from the flag, if the flag is not set we try to u…
Browse files Browse the repository at this point in the history
…se the config file. if that's not set we use default style
  • Loading branch information
gdanko committed Aug 24, 2024
1 parent fcff1d4 commit 35525b7
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ import (
"os"

"github.com/fatih/color"
"github.com/gdanko/enpass/globals"
"github.com/gdanko/enpass/pkg/enpass"
"github.com/sirupsen/logrus"
)

var (
// colorMap = map[string]color.Attribute{
// "AliasColor": color.FgHiYellow,
// "AnchorColor": color.FgHiYellow,
// "BoolColor": color.FgHiYellow,
// "KeyColor": color.FgHiCyan,
// "NullColor": color.FgHiBlack,
// "NumberColor": color.FgHiMagenta,
// "StringColor": color.FgHiGreen,
// }
colorMap = map[string]color.Attribute{
"black-bold": color.FgHiBlack,
"black": color.FgBlack,
Expand Down Expand Up @@ -72,13 +64,26 @@ func GenerateOutput(logger *logrus.Logger, cmdType string, jsonFlag, listFlag, t

if jsonFlag {
doJsonOutput(logger, *cards, nocolorFlag)
} else if yamlFlag {
doYamlOutput(logger, *cards, nocolorFlag)
} else if listFlag {
doListOutput(*cards, cmdType, nocolorFlag)
} else if tableFlag {
doTableOutput(*cards, cmdType)
} else if yamlFlag {
doYamlOutput(logger, *cards, nocolorFlag)
} else {
doDefaultOutput(*cards, cmdType, nocolorFlag)
outputStyle := globals.GetConfig().OutputStyle
if outputStyle != "" {
if outputStyle == "json" {
doJsonOutput(logger, *cards, nocolorFlag)
} else if outputStyle == "list" {
doListOutput(*cards, cmdType, nocolorFlag)
} else if outputStyle == "table" {
doTableOutput(*cards, cmdType)
} else if outputStyle == "yaml" {
doYamlOutput(logger, *cards, nocolorFlag)
}
} else {
doDefaultOutput(*cards, cmdType, nocolorFlag)
}
}
}

0 comments on commit 35525b7

Please sign in to comment.