mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-25 01:04:55 +03:00
minor doc tidy (#63)
This commit is contained in:
parent
929b81c6d3
commit
f2e69603a5
@ -1,12 +1,12 @@
|
||||
# sq: swiss army knife for data
|
||||
|
||||
`sq` is a swiss army knife for data. `sq` provides uniform access to
|
||||
`sq` provides uniform access to
|
||||
structured data sources like traditional SQL-style databases,
|
||||
or document formats such as CSV or Excel. `sq` can perform cross-source joins,
|
||||
execute database-native SQL, and output to a multitude of formats including JSON,
|
||||
Excel, CSV, HTML markdown and XML, or output directly to a SQL database.
|
||||
Excel, CSV, HTML, Markdown and XML, or output directly to a SQL database.
|
||||
`sq` can inspect sources to see metadata about the source structure (tables,
|
||||
columns, size) and has commands for frequent database operations such as copying
|
||||
columns, size) and has commands for common database operations such as copying
|
||||
or dropping tables.
|
||||
|
||||
## Usage
|
||||
|
@ -1,15 +0,0 @@
|
||||
# Package `tablew`
|
||||
|
||||
Package `tablew` implements text table output writers.
|
||||
|
||||
The actual rendering of the text table is handled by a modified version of
|
||||
[`olekukonko/tablewriter`](https://github.com/olekukonko/tablewriter),
|
||||
which can be found in the `internal` sub-package. At the time, `tablewriter`
|
||||
didn't provide all the functionality that sq required. However,
|
||||
that package has been significantly developed since then
|
||||
fork, and it may be possible that we could dispense with the forked
|
||||
version entirely and directly use a newer version of `tablewriter`.
|
||||
|
||||
This entire package could use a rewrite, a lot has changed with sq
|
||||
since this package was first created. So, if you see code in here
|
||||
that doesn't make sense to you, you're probably judging it correctly.
|
@ -7,18 +7,20 @@ import (
|
||||
"github.com/neilotoole/sq/libsq/notify"
|
||||
)
|
||||
|
||||
type NotifyWriter struct {
|
||||
type notifyWriter struct {
|
||||
tbl *table
|
||||
}
|
||||
|
||||
func NewNotifyWriter(out io.Writer, fm *output.Formatting, header bool) *NotifyWriter {
|
||||
// NewNotifyWriter implements output.NotificationWriter.
|
||||
func NewNotifyWriter(out io.Writer, fm *output.Formatting, header bool) output.NotificationWriter {
|
||||
tbl := &table{out: out, header: header, fm: fm}
|
||||
w := &NotifyWriter{tbl: tbl}
|
||||
w := ¬ifyWriter{tbl: tbl}
|
||||
w.tbl.reset()
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *NotifyWriter) NotifyDestinations(dests []notify.Destination) error {
|
||||
// NotifyDestinations implements output.NotificationWriter.
|
||||
func (w *notifyWriter) NotifyDestinations(dests []notify.Destination) error {
|
||||
w.tbl.tblImpl.SetHeader([]string{"NOTIFIER", "TYPE", "TARGET"})
|
||||
var rows [][]string
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
// Package tablew implements text table output writers.
|
||||
//
|
||||
// The actual rendering of the text table is handled by a modified
|
||||
// version ofolekukonko/tablewriter which can be found in the internal
|
||||
// sub-package. At the time, tablewriter didn't provide all the
|
||||
// functionality that sq required. However, that package has been
|
||||
// significantly developed since then fork, and it may be possible
|
||||
// that we could dispense with the forked version entirely and directly
|
||||
// use a newer version of tablewriter.
|
||||
//
|
||||
// This entire package could use a rewrite, a lot has changed with sq
|
||||
// since this package was first created. So, if you see code in here
|
||||
// that doesn't make sense to you, you're probably judging it correctly.
|
||||
package tablew
|
||||
|
||||
import (
|
||||
@ -13,6 +26,7 @@ import (
|
||||
"github.com/neilotoole/sq/libsq/stringz"
|
||||
)
|
||||
|
||||
// table encapsulates the
|
||||
type table struct {
|
||||
fm *output.Formatting
|
||||
out io.Writer
|
@ -139,6 +139,11 @@ func (fs *Files) addFile(f *os.File, key string) (fscache.ReadAtCloser, error) {
|
||||
return nil, errz.Errorf("failed to add to fscache (possibly previously added): %s", key)
|
||||
}
|
||||
|
||||
// TODO: Problematically, we copy the entire contents of f into fscache.
|
||||
// If f is a large file (e.g. piped over stdin), this means that
|
||||
// everything is held up until f is fully copied. Hopefully we can
|
||||
// do something with fscache so that the readers returned from
|
||||
// fscache can lazily read from f.
|
||||
copied, err := io.Copy(w, f)
|
||||
if err != nil {
|
||||
fs.log.WarnIfCloseError(r)
|
||||
|
@ -74,17 +74,17 @@ func TestFiles_DetectType(t *testing.T) {
|
||||
wantOK bool
|
||||
wantErr bool
|
||||
}{
|
||||
//{loc: proj.Abs(sakila.PathSL3), wantType: sqlite3.Type, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/sqlite3/testdata/sakila_db"), wantType: sqlite3.Type, wantOK: true},
|
||||
//{loc: proj.Abs(testsrc.PathXLSXTestHeader), wantType: xlsx.Type, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/xlsx/testdata/test_header_xlsx"), wantType: xlsx.Type, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/xlsx/testdata/test_noheader.xlsx"), wantType: xlsx.Type, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/csv/testdata/person.csv"), wantType: csv.TypeCSV, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/csv/testdata/person_noheader.csv"), wantType: csv.TypeCSV, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/csv/testdata/person_csv"), wantType: csv.TypeCSV, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/csv/testdata/person.tsv"), wantType: csv.TypeTSV, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/csv/testdata/person_noheader.tsv"), wantType: csv.TypeTSV, wantOK: true},
|
||||
//{loc: proj.Abs("drivers/csv/testdata/person_tsv"), wantType: csv.TypeTSV, wantOK: true},
|
||||
{loc: proj.Abs(sakila.PathSL3), wantType: sqlite3.Type, wantOK: true},
|
||||
{loc: proj.Abs("drivers/sqlite3/testdata/sakila_db"), wantType: sqlite3.Type, wantOK: true},
|
||||
{loc: proj.Abs(testsrc.PathXLSXTestHeader), wantType: xlsx.Type, wantOK: true},
|
||||
{loc: proj.Abs("drivers/xlsx/testdata/test_header_xlsx"), wantType: xlsx.Type, wantOK: true},
|
||||
{loc: proj.Abs("drivers/xlsx/testdata/test_noheader.xlsx"), wantType: xlsx.Type, wantOK: true},
|
||||
{loc: proj.Abs("drivers/csv/testdata/person.csv"), wantType: csv.TypeCSV, wantOK: true},
|
||||
{loc: proj.Abs("drivers/csv/testdata/person_noheader.csv"), wantType: csv.TypeCSV, wantOK: true},
|
||||
{loc: proj.Abs("drivers/csv/testdata/person_csv"), wantType: csv.TypeCSV, wantOK: true},
|
||||
{loc: proj.Abs("drivers/csv/testdata/person.tsv"), wantType: csv.TypeTSV, wantOK: true},
|
||||
{loc: proj.Abs("drivers/csv/testdata/person_noheader.tsv"), wantType: csv.TypeTSV, wantOK: true},
|
||||
{loc: proj.Abs("drivers/csv/testdata/person_tsv"), wantType: csv.TypeTSV, wantOK: true},
|
||||
{loc: proj.Abs("README.md"), wantType: source.TypeNone, wantOK: false},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user