mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-19 22:21:56 +03:00
6ca26f4e4f
* wip: refactor col name mungeing * Finished refactoring FieldMeta * Renamed tpl .AlphaIndex to .Alpha * wip: debugging source config override * Source config override passing tests * CHANGELOG update
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// Package outputx contains extensions to pkg output, and helpers
|
|
// for implementing output writers.
|
|
//
|
|
// REVISIT: This package is a bit of an odd duck. Can the functionality
|
|
// be moved elsewhere?
|
|
package outputx
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/neilotoole/sq/libsq/core/options"
|
|
)
|
|
|
|
// VerboseOpt is a verbose realization of an options.Opt value.
|
|
// This is used primarily to print metadata about the opt.
|
|
type VerboseOpt struct {
|
|
Key string `json:"key"`
|
|
Usage string `json:"usage"`
|
|
Type string `json:"type"`
|
|
IsSet bool `json:"is_set"`
|
|
DefaultValue any `json:"default_value"`
|
|
Value any `json:"value"`
|
|
Help string `json:"help"`
|
|
}
|
|
|
|
// NewVerboseOpt returns a VerboseOpt built from opt and o.
|
|
func NewVerboseOpt(opt options.Opt, o options.Options) VerboseOpt {
|
|
v := VerboseOpt{
|
|
Key: opt.Key(),
|
|
Usage: opt.Usage(),
|
|
DefaultValue: opt.GetAny(nil),
|
|
IsSet: o.IsSet(opt),
|
|
Help: opt.Help(),
|
|
Value: opt.GetAny(o),
|
|
Type: reflect.TypeOf(opt.GetAny(nil)).String(),
|
|
}
|
|
|
|
return v
|
|
}
|