-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: adisos <adisos@il.ibm.com>
- Loading branch information
Showing
4 changed files
with
62 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/np-guard/vmware-analyzer/pkg/common" | ||
) | ||
|
||
type outFormat string | ||
|
||
var ( | ||
outFormatText outFormat = common.TextFormat | ||
outFormatDot outFormat = common.DotFormat | ||
outFormatSvg outFormat = common.SvgFormat | ||
outFormatJSON outFormat = common.JSONFormat | ||
) | ||
|
||
var allFormats = []*outFormat{&outFormatText, &outFormatDot, &outFormatSvg, &outFormatJSON} | ||
var allFormatsStr = common.JoinStringifiedSlice(allFormats, common.CommaSeparator) | ||
|
||
// String is used both by fmt.Print and by Cobra in help text | ||
func (e *outFormat) String() string { | ||
return string(*e) | ||
} | ||
|
||
// Set must have pointer receiver so it doesn't change the value of a copy | ||
func (e *outFormat) Set(v string) error { | ||
switch v { | ||
case common.TextFormat, common.DotFormat, common.JSONFormat, common.SvgFormat: | ||
*e = outFormat(v) | ||
return nil | ||
default: | ||
return fmt.Errorf("must be one of %s", allFormatsStr) | ||
} | ||
} | ||
|
||
// Type is only used in help text | ||
func (e *outFormat) Type() string { | ||
return "string" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters