amseltools/main.go

46 lines
857 B
Go

package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"go.xsfx.dev/amseltools/internal/dirtoexcel"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
var rootCmd = &cobra.Command{}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Prints version info",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("amseltools %s, commit %s, build at %s", version, commit, date)
},
}
var dirToExcelCmd = &cobra.Command{
Use: "dir-to-excel [directory]",
Short: "Takes a directory and creates an excel from it",
Run: dirtoexcel.Run,
Args: cobra.ExactArgs(1),
}
func main() {
rootCmd.AddCommand(dirToExcelCmd)
rootCmd.AddCommand(versionCmd)
// Flags.
dirToExcelCmd.Flags().StringP("out", "o", "", "output file")
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}