Skip to content

Commit

Permalink
clear screen
Browse files Browse the repository at this point in the history
  • Loading branch information
robinovitch61 committed Dec 1, 2023
1 parent cd73c3a commit 8305b61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 5 additions & 5 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (

var (
execCmd = &cobra.Command{
Use: "exec",
Short: "Exec into a running task",
Long: `Exec into a running nomad task`,
Run: execEntrypoint,
Use: "exec",
Short: "Exec into a running task",
Long: `Exec into a running nomad task`,
Run: execEntrypoint,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { return nil },
}
)

Expand All @@ -25,7 +26,6 @@ func execEntrypoint(cmd *cobra.Command, args []string) {
allocID := args[0]
task := args[1]
execArgs := args[2:]
fmt.Println(fmt.Sprintf("allocID: %s, task: %s", allocID, task))
_, err = nomad.AllocExec(client, allocID, task, execArgs)
if err != nil {
fmt.Println(fmt.Errorf("could not exec into task: %v", err))
Expand Down
17 changes: 14 additions & 3 deletions internal/tui/nomad/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ import (
"fmt"
"github.com/hashicorp/nomad/api"
"github.com/moby/term"
"github.com/robinovitch61/wander/internal/tui/formatter"
"golang.org/x/sys/unix"
"io"
"os"
"os/signal"
"syscall"
)

// TODO: code review this
// TODO: clear screen on start of exec
// TODO: don't print config file used on exec
// TODO:
// - [ ] code review this
// - [x] clear screen on start of exec
// - [ ] don't print config file used on exec
// - [ ] update gif
// - [ ] cmd human friendly (not full 36char id)
// - [ ] warning message that "you're in wander"
// - [ ] try with bash
// - [ ] improve help text on wander exec

type ExecCompleteMsg struct {
Output string
Expand Down Expand Up @@ -48,6 +55,10 @@ func AllocExec(client *api.Client, allocID, task string, args []string) (int, er
func execImpl(client *api.Client, alloc *api.Allocation, task string,
command []string, escapeChar string, stdin io.Reader, stdout, stderr io.WriteCloser) (int, error) {

// attempt to clear screen
os.Stdout.Write([]byte("\033c"))
fmt.Println(fmt.Sprintf("Exec session for %s (%s), task %s", alloc.Name, formatter.ShortAllocID(alloc.ID), task))

sizeCh := make(chan api.TerminalSize, 1)

ctx, cancelFn := context.WithCancel(context.Background())
Expand Down

0 comments on commit 8305b61

Please sign in to comment.