Add prompt inspection command
This commit is contained in:
@@ -14,14 +14,24 @@ import (
|
||||
|
||||
var ErrUnknownPreparedRunFormat = errors.New("unknown prepared run format")
|
||||
|
||||
// PreparedRunOutputFormat is the output format for prepared render data.
|
||||
type PreparedRunOutputFormat string
|
||||
// OutputFormat selects an application-owned textual or JSON representation.
|
||||
type OutputFormat string
|
||||
|
||||
const (
|
||||
PreparedRunFormatText PreparedRunOutputFormat = "text"
|
||||
PreparedRunFormatJSON PreparedRunOutputFormat = "json"
|
||||
OutputFormatText OutputFormat = "text"
|
||||
OutputFormatJSON OutputFormat = "json"
|
||||
|
||||
DefaultPreparedRunOutputFormat PreparedRunOutputFormat = PreparedRunFormatText
|
||||
DefaultOutputFormat OutputFormat = OutputFormatText
|
||||
)
|
||||
|
||||
// PreparedRunOutputFormat is the output format for prepared render data.
|
||||
type PreparedRunOutputFormat = OutputFormat
|
||||
|
||||
const (
|
||||
PreparedRunFormatText = OutputFormatText
|
||||
PreparedRunFormatJSON = OutputFormatJSON
|
||||
|
||||
DefaultPreparedRunOutputFormat = DefaultOutputFormat
|
||||
)
|
||||
|
||||
// PreparedRunFormatter serializes a prepared run without performing use case work.
|
||||
@@ -31,15 +41,20 @@ type PreparedRunFormatter interface {
|
||||
|
||||
// ParsePreparedRunOutputFormat parses a format name.
|
||||
func ParsePreparedRunOutputFormat(raw string) (PreparedRunOutputFormat, error) {
|
||||
switch PreparedRunOutputFormat(strings.ToLower(strings.TrimSpace(raw))) {
|
||||
return ParseOutputFormat(raw)
|
||||
}
|
||||
|
||||
// ParseOutputFormat parses the shared inspection and prepared-run format names.
|
||||
func ParseOutputFormat(raw string) (OutputFormat, error) {
|
||||
switch OutputFormat(strings.ToLower(strings.TrimSpace(raw))) {
|
||||
case "":
|
||||
return DefaultPreparedRunOutputFormat, nil
|
||||
case PreparedRunFormatText:
|
||||
return PreparedRunFormatText, nil
|
||||
case PreparedRunFormatJSON:
|
||||
return PreparedRunFormatJSON, nil
|
||||
return DefaultOutputFormat, nil
|
||||
case OutputFormatText:
|
||||
return OutputFormatText, nil
|
||||
case OutputFormatJSON:
|
||||
return OutputFormatJSON, nil
|
||||
default:
|
||||
return "", fmt.Errorf("%w: %q (supported: %s, %s)", ErrUnknownPreparedRunFormat, raw, PreparedRunFormatText, PreparedRunFormatJSON)
|
||||
return "", fmt.Errorf("%w: %q (supported: %s, %s)", ErrUnknownPreparedRunFormat, raw, OutputFormatText, OutputFormatJSON)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user