Files
gothermal/cmd/message.go
T
2024-05-02 21:19:44 +01:00

34 lines
652 B
Go

/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd
import (
thermalprinter "thermalPrinter/thermalPrinter"
"github.com/spf13/cobra"
)
func messageCmdAction(cmd *cobra.Command, args []string) {
message, _ := cmd.Flags().GetString("message")
printer := thermalprinter.GetInstance(nil)
printer.Print(message)
}
// messageCmd represents the message command
var messageCmd = &cobra.Command{
Use: "message",
Short: "",
Long: ``,
Run: messageCmdAction,
}
func init() {
rootCmd.AddCommand(messageCmd)
messageCmd.Flags().StringP("message", "m", "Hello, world!\n", "Message to print")
messageCmd.MarkFlagRequired("message")
}