Documentation ¶
Index ¶
- Variables
- func ConfigTableWriter(t *tw.Table, opts RenderOptions)
- func Execute()
- func FromStringArray(strs []string, out []Alignment) error
- func NewBufWriteCloser(f *os.File, buf *bufio.Writer) io.WriteCloser
- func Render(r *csv.Reader, w io.Writer, opts RenderOptions) error
- type Alignment
- type BufWriteCloser
- type RenderOptions
Constants ¶
This section is empty.
Variables ¶
var BuildDate = "dev-build"
BuildDate defines the date this build was built
var ErrUnknownAlignment = fmt.Errorf("unknown alignment")
ErrUnknownAlignment Returned when the passed in alignment character isn't a valid Alignment type.
var RootCmd = &cobra.Command{
Use: "csvtk",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
}
RootCmd represents the base command when called without any subcommands
var Version = "dev-build"
Version defines the version of the tool
Functions ¶
func ConfigTableWriter ¶
func ConfigTableWriter(t *tw.Table, opts RenderOptions)
ConfigTableWriter takes a pointer to a Table and configures it based on the passed in opts
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func FromStringArray ¶
FromStringArray accepts an array of strings and attempts to convert them into an Alignment type. Any error will break the conversion and return an ErrUnknownAlignment
func NewBufWriteCloser ¶
NewBufWriteCloser creates a new BufWriteCloser type using f to read from and buf to write to.
Types ¶
type Alignment ¶
type Alignment string
Alignment An alignment specifies how a header, column, or footer should be aligned while rendering.
const ( // AlignDefault will align the header, column, or footer in the default manner. AlignDefault Alignment = "=" // AlignCenter will align the header, column, or footer to the center. AlignCenter Alignment = "-" // AlignLeft will align the header, column, or footer to the left. AlignLeft Alignment = "<" // AlignRight will align the header, column, or footer to the right. AlignRight Alignment = ">" // AlignEmpty only used during an error state. AlignEmpty Alignment = "" )
func FromString ¶
FromString accepts a string and converts it into an Alignment type. If the alignment is invalid it will return an ErrUnknownAlignment
func (Alignment) ToString ¶
ToString will convert the Alignment type into its associated string value.
func (Alignment) ToTableWriter ¶
ToTableWriter will convert the alignment to a TableWriter format
type BufWriteCloser ¶
BufWriteCloser provides a WriteCloser for a bufio.Writer
func (*BufWriteCloser) Close ¶
func (b *BufWriteCloser) Close() error
Close when done with the BufWriteCloser you should call Close() to clean up resources.
type RenderOptions ¶
type RenderOptions struct { Align Alignment AlignColumns []Alignment AlignHeader Alignment AutoFormattingHeaders bool AutoMergeCells bool AutoWrap bool Caption string CenterSeparator string ColumnSeparator string ColWidth int FirstRowAsHeader bool Header []string Newline string Reflow bool RowLine bool RowSeparator string }
RenderOptions defines the various rendering options available