Skip to content

Commit

Permalink
refactor stream cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmvrk committed Nov 19, 2024
1 parent 31db883 commit cfbacdb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@ const (

// streamCmd represents the new command for streaming functionality
var streamCmd = &cobra.Command{
Use: "stream [file]",
Short: "Stream data to your agent",
Long: `The stream command allows you to initiate a data stream to your agent.`,
Use: "stream --file [filename]",
Short: "Parse stream data from agent",
Long: `Allows you to parse a data stream to your agent response.`,
Run: agentStream,
}

func init() {
streamCmd.PersistentFlags().String(streamCmdFileFlag, "", "Parse agent responses from a file")
rootCmd.AddCommand(streamCmd)
}

func agentStream(cmd *cobra.Command, args []string) {
fmt.Println("stream command executed successfully")

file := args[0]
file, _ := cmd.Flags().GetString(streamCmdFileFlag)
if file == "" {
fmt.Fprintln(os.Stderr, "Error: --file [file] is required")
os.Exit(1)
}

result, err := stream.ParseFile(file)
if err != nil {
Expand Down

0 comments on commit cfbacdb

Please sign in to comment.