github.com/scaleway/scaleway-cli@v1.11.1/pkg/commands/attach.go (about)

     1  // Copyright (C) 2015 Scaleway. All rights reserved.
     2  // Use of this source code is governed by a MIT-style
     3  // license that can be found in the LICENSE.md file.
     4  
     5  package commands
     6  
     7  import "github.com/scaleway/scaleway-cli/pkg/utils"
     8  
     9  // AttachArgs are flags for the `RunAttach` function
    10  type AttachArgs struct {
    11  	NoStdin bool
    12  	Server  string
    13  }
    14  
    15  // RunAttach is the handler for 'scw attach'
    16  func RunAttach(ctx CommandContext, args AttachArgs) error {
    17  	serverID, err := ctx.API.GetServerID(args.Server)
    18  	if err != nil {
    19  		return err
    20  	}
    21  	_, done, err := utils.AttachToSerial(serverID, ctx.API.Token, ctx.API.ResolveTTYUrl())
    22  	if err != nil {
    23  		return err
    24  	}
    25  	<-done
    26  	return nil
    27  }