First commit with a basic mockserver for BeamNG stuff

This commit is contained in:
2025-10-02 00:09:45 +01:00
commit 47cacaf16b
7 changed files with 170 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package cmd
import (
"fmt"
"github.com/ESilva15/BeamNGMockOg/mockserver"
"github.com/spf13/cobra"
)
func replayAction(cmd *cobra.Command, args []string) {
inputFile, _ := cmd.Flags().GetString("input")
address, _ := cmd.Flags().GetString("address")
port, _ := cmd.Flags().GetInt("port")
if err := mockserver.Replay(address, port, inputFile); err != nil {
fmt.Printf("Something went wrong while playing the file: %v", err)
}
}
// shelf
var replayCmd = &cobra.Command{
Use: "replay",
Short: "replay -i <path-to-bin-file>",
Long: `replay will store the data from the given UDP server to the
filepath given by -i`,
Args: nil,
Run: replayAction,
}
func init() {
rootCmd.AddCommand(replayCmd)
replayCmd.PersistentFlags().StringP("input", "i", "nofile.bin", "input file for serving")
}