diskii/cmd/filetypes.go

29 lines
775 B
Go
Raw Permalink 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-08-01 03:49:22 +00:00
// FiletypesCmd is the kong `filetypes` command.
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-08-01 03:49:22 +00:00
// Run the `filetypes` command.
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-08-01 03:49:22 +00:00
_ = w.Flush()
return nil
}