42 lines
956 B
Go
42 lines
956 B
Go
/*
|
|
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
|
*/
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"thermalPrinter/server"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func serverCmdAction(cmd *cobra.Command, args []string) {
|
|
http.HandleFunc("/print", server.LaunchServer)
|
|
fmt.Println("Starting server on port 8083")
|
|
log.Fatal(http.ListenAndServe(":8083", nil))
|
|
}
|
|
|
|
// serverCmd represents the server command
|
|
var serverCmd = &cobra.Command{
|
|
Use: "server",
|
|
Short: "",
|
|
Long: ``,
|
|
Run: serverCmdAction,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(serverCmd)
|
|
|
|
// Here you will define your flags and configuration settings.
|
|
|
|
// Cobra supports Persistent Flags which will work for this command
|
|
// and all subcommands, e.g.:
|
|
// serverCmd.PersistentFlags().String("foo", "", "A help for foo")
|
|
|
|
// Cobra supports local flags which will only run when this command
|
|
// is called directly, e.g.:
|
|
// serverCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
|
}
|