diff options
author | bnewbold <bnewbold@robocracy.org> | 2012-09-21 13:03:46 +0200 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2012-09-21 13:03:46 +0200 |
commit | 575dd002be18f170917a98f8bca891b4bd615f78 (patch) | |
tree | 5db7245e184110fd0a403b052191fe6d5b3205d4 /formats.go | |
parent | b0ecc94ef69d489dcc775038a0c6f65c1c960c8e (diff) | |
download | bommom-575dd002be18f170917a98f8bca891b4bd615f78.tar.gz bommom-575dd002be18f170917a98f8bca891b4bd615f78.zip |
basic octopart pricing functionality
Diffstat (limited to 'formats.go')
-rw-r--r-- | formats.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -53,6 +53,22 @@ func DumpBomAsText(bm *BomMeta, b *Bom, out io.Writer) { tabWriter.Flush() } +func DumpBomMarketInfo(bm *BomMeta, b *Bom, out io.Writer) { + fmt.Fprintln(out) + tabWriter := tabwriter.NewWriter(out, 2, 4, 1, ' ', 0) + // "by line item", not "by element" + fmt.Fprintf(tabWriter, "qty\tmanufacturer\tmpn\t\tavg_price\tfactor\n") + for _, li := range b.LineItems { + fmt.Fprintf(tabWriter, "%d\t%s\t%s\t\t%s\t%s\n", + len(li.Elements), + li.Manufacturer, + li.Mpn, + li.AggregateInfo["MarketPrice"], + li.AggregateInfo["MarketFactor"]) + } + tabWriter.Flush() +} + // --------------------- csv ----------------------- func DumpBomAsCSV(b *Bom, out io.Writer) { |