diskii/main.go

57 lines
1.2 KiB
Go
Raw Normal View History

2021-06-26 02:33:11 +00:00
// Copyright ©2021 Zellyn Hunter <zellyn@gmail.com>
package main
import (
"github.com/zellyn/diskii/cmd"
2021-06-26 02:33:11 +00:00
"github.com/zellyn/diskii/dos3"
"github.com/zellyn/diskii/prodos"
"github.com/zellyn/diskii/supermon"
2021-06-26 02:33:11 +00:00
"github.com/zellyn/diskii/types"
2021-06-26 02:33:11 +00:00
"fmt"
"os"
"github.com/alecthomas/kong"
)
2021-06-26 02:33:11 +00:00
var cli struct {
Debug bool `kong:"short='v',help='Enable debug mode.'"`
2021-06-26 02:33:11 +00:00
2021-07-12 21:02:11 +00:00
Ls cmd.LsCmd `cmd:"" aliases:"cat,catalog" help:"List paths."`
Reorder cmd.ReorderCmd `cmd:"" help:"Reorder disk images."`
Filetypes cmd.FiletypesCmd `cmd:"" help:"Print a list of filetypes understood by diskii."`
2021-06-26 02:33:11 +00:00
}
func run() error {
ctx := kong.Parse(&cli,
kong.Name("diskii"),
kong.Description("A commandline tool for working with Apple II disk images."),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: true,
}),
)
globals := &types.Globals{
Debug: cli.Debug,
2021-06-26 02:33:11 +00:00
DiskOperatorFactories: []types.OperatorFactory{
dos3.OperatorFactory{},
supermon.OperatorFactory{},
prodos.OperatorFactory{},
2021-06-26 02:33:11 +00:00
},
}
// Call the Run() method of the selected parsed command.
return ctx.Run(globals)
}
func main() {
2021-06-26 02:33:11 +00:00
err := run()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}