Moved the code its respective places instead of being all mixed up
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
// Package cmd contains our cli
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "esdi",
|
||||
Short: "CLI for the dashDisplay project",
|
||||
Long: `Allows the configuration and communication with the dashDisplay`,
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.Flags().StringP("out", "o", "", "output file")
|
||||
rootCmd.Flags().StringP("session", "s", "", "output session info to file")
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"esdi/esdi"
|
||||
"esdi/logger"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func liveTelemetryCmdAction(cmd *cobra.Command, args []string) {
|
||||
log := logger.GetInstance()
|
||||
|
||||
ddPort, _ := cmd.Flags().GetString("port")
|
||||
outputFile, _ := cmd.Flags().GetString("out")
|
||||
sessionFile, _ := cmd.Flags().GetString("session")
|
||||
|
||||
log.Printf("Called `live`:\nPort: '%s'\nOutFile: '%s'\n", ddPort, outputFile)
|
||||
|
||||
esdi.RunLiveTelemetry(ddPort, outputFile, sessionFile)
|
||||
}
|
||||
|
||||
// removeLabelCmd represents the removeLabel command
|
||||
var liveTelemetryCmd = &cobra.Command{
|
||||
Use: "live",
|
||||
Short: "stream data directly from the game",
|
||||
Long: ``,
|
||||
Run: liveTelemetryCmdAction,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(liveTelemetryCmd)
|
||||
|
||||
// Declare the flags for this command
|
||||
liveTelemetryCmd.Flags().StringP("port", "p", "", "dashDisplay Port")
|
||||
// liveTelemetryCmd.Flags().StringP("out", "o", "", "output to an .ibt file")
|
||||
// liveTelemetryCmd.Flags().StringP("session", "s", "", "output session .yaml to file")
|
||||
|
||||
// Mark the required ones
|
||||
liveTelemetryCmd.MarkFlagRequired("port")
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"esdi/esdi"
|
||||
"esdi/logger"
|
||||
|
||||
// "github.com/ESilva15/goirsdk"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func offlineTelemetryCmdAction(cmd *cobra.Command, args []string) {
|
||||
log := logger.GetInstance()
|
||||
|
||||
ddPort, _ := cmd.Flags().GetString("port")
|
||||
inFile, _ := cmd.Flags().GetString("in")
|
||||
outFile, _ := cmd.Flags().GetString("out")
|
||||
sessionFile, _ := cmd.Flags().GetString("session")
|
||||
|
||||
log.Printf("Called `offline`:\nPort: '%s'\nSource: '%s'\nOutFile: '%s'\n", ddPort, inFile, outFile)
|
||||
|
||||
esdi.RunOfflineTelemetry(ddPort, inFile, outFile, sessionFile)
|
||||
}
|
||||
|
||||
// removeLabelCmd represents the removeLabel command
|
||||
var offlineTelemetryCmd = &cobra.Command{
|
||||
Use: "offline",
|
||||
Short: "stream data from a file",
|
||||
Long: ``,
|
||||
Run: offlineTelemetryCmdAction,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(offlineTelemetryCmd)
|
||||
|
||||
// Declare the flags for this command
|
||||
offlineTelemetryCmd.Flags().StringP("port", "p", "", "dashDisplay Port")
|
||||
offlineTelemetryCmd.Flags().StringP("in", "i", "", "source file")
|
||||
|
||||
// Mark the required ones
|
||||
offlineTelemetryCmd.MarkFlagRequired("port")
|
||||
offlineTelemetryCmd.MarkFlagRequired("in")
|
||||
}
|
||||
Reference in New Issue
Block a user