Skip to content

Commit

Permalink
feat: #37 add quiet flag to disable Cluster/Service/Task output
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsmitt committed Dec 29, 2023
1 parent dfae2b2 commit 23d1af7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func init() {
rootCmd.PersistentFlags().StringP("container", "u", "", "Container name")
rootCmd.PersistentFlags().BoolP("forward", "f", false, "Port Forward")
rootCmd.PersistentFlags().StringP("local-port", "l", "", "Local port for use with port forwarding")
rootCmd.PersistentFlags().BoolP("quiet", "q", false, "Do not print cluster and container information")

viper.BindPFlag("cmd", rootCmd.PersistentFlags().Lookup("cmd"))
viper.BindPFlag("profile", rootCmd.PersistentFlags().Lookup("profile"))
Expand All @@ -103,4 +104,5 @@ func init() {
viper.BindPFlag("container", rootCmd.PersistentFlags().Lookup("container"))
viper.BindPFlag("forward", rootCmd.PersistentFlags().Lookup("forward"))
viper.BindPFlag("local-port", rootCmd.PersistentFlags().Lookup("local-port"))
viper.BindPFlag("quiet", rootCmd.PersistentFlags().Lookup("quiet"))
}
6 changes: 4 additions & 2 deletions internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ func (e *App) executeCommand() error {
}

// Print Cluster/Service/Task information to the console
fmt.Printf("\nCluster: %v | Service: %v | Task: %s | Cmd: %s", Cyan(e.cluster), Magenta(e.service), Green(strings.Split(*e.task.TaskArn, "/")[2]), Yellow(command))
fmt.Printf("\nConnecting to container %v\n", Yellow(*e.container.Name))
if !viper.GetBool("quiet") {
fmt.Printf("\nCluster: %v | Service: %v | Task: %s | Cmd: %s", Cyan(e.cluster), Magenta(e.service), Green(strings.Split(*e.task.TaskArn, "/")[2]), Yellow(command))
fmt.Printf("\nConnecting to container %v\n", Yellow(*e.container.Name))
}

// Execute the session-manager-plugin with our task details
err = runCommand("session-manager-plugin", string(execSess), e.region, "StartSession", "", string(targetJson), e.endpoint)
Expand Down
6 changes: 4 additions & 2 deletions internal/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ func (e *App) executeForward() error {
}

// Print Cluster/Service/Task information to the console
fmt.Printf("\nCluster: %v | Service: %v | Task: %s", Cyan(e.cluster), Magenta(e.service), Green(strings.Split(*e.task.TaskArn, "/")[2]))
fmt.Printf("\nPort-forwarding %s:%d -> container %v\n", localPort, *containerPort, Yellow(*e.container.Name))
if !viper.GetBool("quiet") {
fmt.Printf("\nCluster: %v | Service: %v | Task: %s", Cyan(e.cluster), Magenta(e.service), Green(strings.Split(*e.task.TaskArn, "/")[2]))
fmt.Printf("\nPort-forwarding %s:%d -> container %v\n", localPort, *containerPort, Yellow(*e.container.Name))
}

// Execute the session-manager-plugin with our task details
err = runCommand("session-manager-plugin", string(sessJson), e.region, "StartSession", "", string(paramsJson))
Expand Down

0 comments on commit 23d1af7

Please sign in to comment.