@@ -123,6 +123,15 @@ container-use config show my-env
123123 fmt .Fprintf (tw , "Setup Commands:\t (none)\n " )
124124 }
125125
126+ if len (config .InstallCommands ) > 0 {
127+ fmt .Fprintf (tw , "Install Commands:\t \n " )
128+ for i , cmd := range config .InstallCommands {
129+ fmt .Fprintf (tw , " %d.\t %s\n " , i + 1 , cmd )
130+ }
131+ } else {
132+ fmt .Fprintf (tw , "Install Commands:\t (none)\n " )
133+ }
134+
126135 envKeys := config .Env .Keys ()
127136 if len (envKeys ) > 0 {
128137 fmt .Fprintf (tw , "Environment Variables:\t \n " )
@@ -316,6 +325,89 @@ var configSetupCommandClearCmd = &cobra.Command{
316325 },
317326}
318327
328+ // Install command object commands
329+ var configInstallCommandCmd = & cobra.Command {
330+ Use : "install-command" ,
331+ Short : "Manage install commands" ,
332+ Long : `Manage install commands that are run after copying code to environments.` ,
333+ }
334+
335+ var configInstallCommandAddCmd = & cobra.Command {
336+ Use : "add <command>" ,
337+ Short : "Add an install command" ,
338+ Long : `Add a command to be run after copying code to new environments (e.g., "go mod download").` ,
339+ Args : cobra .ExactArgs (1 ),
340+ RunE : func (cmd * cobra.Command , args []string ) error {
341+ command := args [0 ]
342+ return updateConfig (cmd , func (config * environment.EnvironmentConfig ) error {
343+ config .InstallCommands = append (config .InstallCommands , command )
344+ fmt .Printf ("Install command added: %s\n " , command )
345+ return nil
346+ })
347+ },
348+ }
349+
350+ var configInstallCommandRemoveCmd = & cobra.Command {
351+ Use : "remove <command>" ,
352+ Short : "Remove an install command" ,
353+ Long : `Remove an install command from the environment configuration.` ,
354+ Args : cobra .ExactArgs (1 ),
355+ RunE : func (cmd * cobra.Command , args []string ) error {
356+ command := args [0 ]
357+ return updateConfig (cmd , func (config * environment.EnvironmentConfig ) error {
358+ found := false
359+ newCommands := make ([]string , 0 , len (config .InstallCommands ))
360+ for _ , existing := range config .InstallCommands {
361+ if existing != command {
362+ newCommands = append (newCommands , existing )
363+ } else {
364+ found = true
365+ }
366+ }
367+
368+ if ! found {
369+ return fmt .Errorf ("install command not found: %s" , command )
370+ }
371+
372+ config .InstallCommands = newCommands
373+ fmt .Printf ("Install command removed: %s\n " , command )
374+ return nil
375+ })
376+ },
377+ }
378+
379+ var configInstallCommandListCmd = & cobra.Command {
380+ Use : "list" ,
381+ Short : "List all install commands" ,
382+ Long : `List all install commands that will be run after copying code to environments.` ,
383+ RunE : func (cmd * cobra.Command , args []string ) error {
384+ return withConfig (cmd , func (config * environment.EnvironmentConfig ) error {
385+ if len (config .InstallCommands ) == 0 {
386+ fmt .Println ("No install commands configured" )
387+ return nil
388+ }
389+
390+ for i , command := range config .InstallCommands {
391+ fmt .Printf ("%d. %s\n " , i + 1 , command )
392+ }
393+ return nil
394+ })
395+ },
396+ }
397+
398+ var configInstallCommandClearCmd = & cobra.Command {
399+ Use : "clear" ,
400+ Short : "Clear all install commands" ,
401+ Long : `Remove all install commands from the environment configuration.` ,
402+ RunE : func (cmd * cobra.Command , args []string ) error {
403+ return updateConfig (cmd , func (config * environment.EnvironmentConfig ) error {
404+ config .InstallCommands = []string {}
405+ fmt .Println ("All install commands cleared" )
406+ return nil
407+ })
408+ },
409+ }
410+
319411// Environment variable object commands
320412var configEnvCmd = & cobra.Command {
321413 Use : "env" ,
@@ -476,6 +568,12 @@ func init() {
476568 configSetupCommandCmd .AddCommand (configSetupCommandListCmd )
477569 configSetupCommandCmd .AddCommand (configSetupCommandClearCmd )
478570
571+ // Add install-command commands
572+ configInstallCommandCmd .AddCommand (configInstallCommandAddCmd )
573+ configInstallCommandCmd .AddCommand (configInstallCommandRemoveCmd )
574+ configInstallCommandCmd .AddCommand (configInstallCommandListCmd )
575+ configInstallCommandCmd .AddCommand (configInstallCommandClearCmd )
576+
479577 // Add env commands
480578 configEnvCmd .AddCommand (configEnvSetCmd )
481579 configEnvCmd .AddCommand (configEnvUnsetCmd )
@@ -491,6 +589,7 @@ func init() {
491589 // Add object commands to config
492590 configCmd .AddCommand (configBaseImageCmd )
493591 configCmd .AddCommand (configSetupCommandCmd )
592+ configCmd .AddCommand (configInstallCommandCmd )
494593 configCmd .AddCommand (configEnvCmd )
495594 configCmd .AddCommand (configSecretCmd )
496595 configCmd .AddCommand (configShowCmd )
0 commit comments