Skip to content

Commit cfbacdb

Browse files
committed
refactor stream cmd
1 parent 31db883 commit cfbacdb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cmd/stream.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,25 @@ const (
1515

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

2424
func init() {
2525
streamCmd.PersistentFlags().String(streamCmdFileFlag, "", "Parse agent responses from a file")
26+
rootCmd.AddCommand(streamCmd)
2627
}
2728

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

31-
file := args[0]
32+
file, _ := cmd.Flags().GetString(streamCmdFileFlag)
33+
if file == "" {
34+
fmt.Fprintln(os.Stderr, "Error: --file [file] is required")
35+
os.Exit(1)
36+
}
3237

3338
result, err := stream.ParseFile(file)
3439
if err != nil {

0 commit comments

Comments
 (0)