Use tabwriter for list

Signed-off-by: jolheiser <john.olheiser@gmail.com>
pull/7/head
jolheiser 2021-02-27 22:54:01 -06:00
parent 2220ab17eb
commit e0817ea38c
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 8 additions and 3 deletions

View File

@ -1,8 +1,11 @@
package cmd
import (
"fmt"
"os"
"text/tabwriter"
"github.com/urfave/cli/v2"
"go.jolheiser.com/beaver"
)
var List = cli.Command{
@ -17,8 +20,10 @@ func doList(_ *cli.Context) error {
if err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
for _, pkg := range pkgs {
beaver.Infof("%s ->\t%s", pkg.Name, pkg.Import)
s := fmt.Sprintf("%s\t%s\n", pkg.Name, pkg.Import)
_, _ = w.Write([]byte(s))
}
return nil
return w.Flush()
}