@@ -46,11 +46,11 @@ func NewRootCmd() *cobra.Command {
4646
4747 // Persistent flags (global options available to all subcommands)
4848 pf := cmd .PersistentFlags ()
49- pf .String ("input-file" , "" , "Raw recording zip file path" )
50- pf .String ("input-dir" , "" , "Raw recording directory path" )
51- pf .String ("input-s3" , "" , "Raw recording S3 path" )
52- pf .String ("output" , "" , "Output directory" )
53- pf .Bool ("verbose" , false , "Enable verbose logging" )
49+ pf .String (FlagInputFile , "" , DescInputFile )
50+ pf .String (FlagInputDir , "" , DescInputDir )
51+ pf .String (FlagInputS3 , "" , DescInputS3 )
52+ pf .String (FlagOutput , "" , DescOutput )
53+ pf .Bool (FlagVerbose , false , DescVerbose )
5454
5555 // Add subcommands
5656 cmd .AddCommand (
@@ -67,11 +67,11 @@ func NewRootCmd() *cobra.Command {
6767
6868// getGlobalArgs extracts global arguments from cobra command flags
6969func getGlobalArgs (cmd * cobra.Command ) (* GlobalArgs , error ) {
70- inputFile , _ := cmd .Flags ().GetString ("input-file" )
71- inputDir , _ := cmd .Flags ().GetString ("input-dir" )
72- inputS3 , _ := cmd .Flags ().GetString ("input-s3" )
73- output , _ := cmd .Flags ().GetString ("output" )
74- verbose , _ := cmd .Flags ().GetBool ("verbose" )
70+ inputFile , _ := cmd .Flags ().GetString (FlagInputFile )
71+ inputDir , _ := cmd .Flags ().GetString (FlagInputDir )
72+ inputS3 , _ := cmd .Flags ().GetString (FlagInputS3 )
73+ output , _ := cmd .Flags ().GetString (FlagOutput )
74+ verbose , _ := cmd .Flags ().GetBool (FlagVerbose )
7575
7676 return & GlobalArgs {
7777 InputFile : inputFile ,
@@ -85,7 +85,7 @@ func getGlobalArgs(cmd *cobra.Command) (*GlobalArgs, error) {
8585// validateGlobalArgs validates global arguments
8686func validateGlobalArgs (globalArgs * GlobalArgs , requireOutput bool ) error {
8787 if globalArgs .InputFile == "" && globalArgs .InputDir == "" && globalArgs .InputS3 == "" {
88- return fmt .Errorf ("either --input-file or --input-dir or --input-s3 must be specified" )
88+ return fmt .Errorf ("either --%s or --%s or --%s must be specified" , FlagInputFile , FlagInputDir , FlagInputS3 )
8989 }
9090
9191 num := 0
@@ -99,11 +99,11 @@ func validateGlobalArgs(globalArgs *GlobalArgs, requireOutput bool) error {
9999 num ++
100100 }
101101 if num > 1 {
102- return fmt .Errorf ("--input-file , --input-dir and --input-s3 are exclusive, only one is allowed" )
102+ return fmt .Errorf ("--%s , --%s and --%s are exclusive, only one is allowed" , FlagInputFile , FlagInputDir , FlagInputS3 )
103103 }
104104
105105 if requireOutput && globalArgs .Output == "" {
106- return fmt .Errorf ("--output directory must be specified" )
106+ return fmt .Errorf ("--%s directory must be specified" , FlagOutput )
107107 }
108108
109109 return nil
@@ -125,7 +125,7 @@ func validateInputArgs(globalArgs *GlobalArgs, userID, sessionID, trackID string
125125
126126 // Ensure filters are mutually exclusive
127127 if filtersCount > 1 {
128- return nil , fmt .Errorf ("only one filter can be specified at a time: --user-id , --session-id , and --track-id are mutually exclusive" )
128+ return nil , fmt .Errorf ("only one filter can be specified at a time: --%s , --%s , and --%s are mutually exclusive" , FlagUserID , FlagSessionID , FlagTrackID )
129129 }
130130
131131 var inputPath string
@@ -160,7 +160,7 @@ func validateInputArgs(globalArgs *GlobalArgs, userID, sessionID, trackID string
160160 }
161161 }
162162 if ! found {
163- return nil , fmt .Errorf ("track-id '%s' not found in recording. Use 'list-tracks --format tracks' to see available track IDs" , trackID )
163+ return nil , fmt .Errorf ("%s '%s' not found in recording. Use 'list-tracks --%s tracks' to see available track IDs" , FlagTrackID , trackID , FlagFormat )
164164 }
165165 } else if sessionID != "" {
166166 found := false
@@ -171,7 +171,7 @@ func validateInputArgs(globalArgs *GlobalArgs, userID, sessionID, trackID string
171171 }
172172 }
173173 if ! found {
174- return nil , fmt .Errorf ("session-id '%s' not found in recording. Use 'list-tracks --format sessions' to see available session IDs" , sessionID )
174+ return nil , fmt .Errorf ("%s '%s' not found in recording. Use 'list-tracks --%s sessions' to see available session IDs" , FlagSessionID , sessionID , FlagFormat )
175175 }
176176 } else if userID != "" {
177177 found := false
@@ -182,7 +182,7 @@ func validateInputArgs(globalArgs *GlobalArgs, userID, sessionID, trackID string
182182 }
183183 }
184184 if ! found {
185- return nil , fmt .Errorf ("user-id '%s' not found in recording. Use 'list-tracks --format users' to see available user IDs" , userID )
185+ return nil , fmt .Errorf ("%s '%s' not found in recording. Use 'list-tracks --%s users' to see available user IDs" , FlagUserID , userID , FlagFormat )
186186 }
187187 }
188188
@@ -217,8 +217,8 @@ func prepareWorkDir(globalArgs *GlobalArgs, logger *getstream.DefaultLogger) (st
217217
218218// completeUserIDs provides completion for user IDs
219219func completeUserIDs (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
220- inputFile , _ := cmd .Flags ().GetString ("input-file" )
221- inputDir , _ := cmd .Flags ().GetString ("input-dir" )
220+ inputFile , _ := cmd .Flags ().GetString (FlagInputFile )
221+ inputDir , _ := cmd .Flags ().GetString (FlagInputDir )
222222
223223 inputPath := inputFile
224224 if inputPath == "" {
@@ -240,8 +240,8 @@ func completeUserIDs(cmd *cobra.Command, args []string, toComplete string) ([]st
240240
241241// completeSessionIDs provides completion for session IDs
242242func completeSessionIDs (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
243- inputFile , _ := cmd .Flags ().GetString ("input-file" )
244- inputDir , _ := cmd .Flags ().GetString ("input-dir" )
243+ inputFile , _ := cmd .Flags ().GetString (FlagInputFile )
244+ inputDir , _ := cmd .Flags ().GetString (FlagInputDir )
245245
246246 inputPath := inputFile
247247 if inputPath == "" {
@@ -263,8 +263,8 @@ func completeSessionIDs(cmd *cobra.Command, args []string, toComplete string) ([
263263
264264// completeTrackIDs provides completion for track IDs
265265func completeTrackIDs (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
266- inputFile , _ := cmd .Flags ().GetString ("input-file" )
267- inputDir , _ := cmd .Flags ().GetString ("input-dir" )
266+ inputFile , _ := cmd .Flags ().GetString (FlagInputFile )
267+ inputDir , _ := cmd .Flags ().GetString (FlagInputDir )
268268
269269 inputPath := inputFile
270270 if inputPath == "" {
0 commit comments