diskii/cmd/filetypes.go

27 lines
690 B
Go
Raw Normal View History

// Copyright © 2016 Zellyn Hunter <zellyn@gmail.com>
package cmd
import (
"fmt"
"os"
2021-07-12 21:02:11 +00:00
"text/tabwriter"
2021-06-26 02:33:11 +00:00
"github.com/zellyn/diskii/types"
)
2021-07-12 21:02:11 +00:00
type FiletypesCmd struct {
All bool `kong:"help='Display all types, including SOS types and reserved ranges.'"`
}
2021-07-12 21:02:11 +00:00
func (f *FiletypesCmd) Run(globals *types.Globals) error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
fmt.Fprintln(w, "Description\tName\tThree-letter Name\tOne-letter Name")
fmt.Fprintln(w, "-----------\t----\t-----------------\t---------------")
for _, typ := range types.FiletypeInfos(f.All) {
fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", typ.Desc, typ.Name, typ.ThreeLetter, typ.OneLetter)
}
2021-07-12 21:02:11 +00:00
w.Flush()
return nil
}