func (ui consoleUi) PrintTable(table *tablewriter.Table) (int, error) {
	if printOutput() {
		table.Render()
	}

	return 0, nil
}
Example #2
0
// makeNews returns TOP 30 from hackernews
func makeNews(news *News, top int, table *tablewriter.Table, wg *sync.WaitGroup) {
	defer wg.Done()
	storyURL := fmt.Sprintf("https://hacker-news.firebaseio.com/v0/item/%s.json", strconv.Itoa(top))
	story, err := http.Get(storyURL)
	defer story.Body.Close()
	if err != nil {
		fmt.Errorf(err.Error())
	}
	json.NewDecoder(story.Body).Decode(&news)
	table.Append([]string{news.Title, news.URL})
}
Example #3
0
File: repl.go Project: tsandall/opa
func (r *REPL) printPrettyRow(table *tablewriter.Table, keys []string, row map[string]interface{}) {

	buf := []string{}
	for _, k := range keys {
		js, err := json.Marshal(row[k])
		if err != nil {
			buf = append(buf, err.Error())
		} else {
			buf = append(buf, string(js))
		}
	}

	// Add fields to table in sorted order.
	table.Append(buf)
}
func (p defaultPrinter) PrintTable(table *tablewriter.Table) (int, error) {
	table.Render()

	return 0, nil
}
Example #5
0
func (r *Results) writeRows(t *tablewriter.Table, es *EntrySet) {
	for _, e := range es.Entries {
		t.Append(e.Row())
	}
}
func (fakeUi *FakeUi) PrintTable(table *tablewriter.Table) (int, error) {
	table.Render()

	return 0, nil
}