/
command.go
35 lines (28 loc) · 869 Bytes
/
command.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (C) 2015 Scaleway. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.md file.
// Package commands contains the workflows behind each commands of the CLI (run, attach, start, exec, commit, ...)
package commands
import (
"io"
"os"
"github.com/scaleway/scaleway-cli/pkg/api"
)
// Streams is used to redirects the streams
type Streams struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
// CommandContext is passed to all commands and contains streams, environment, api and arguments
type CommandContext struct {
Streams
Env []string
RawArgs []string
API *api.ScalewayAPI
}
// Getenv returns the equivalent of os.Getenv for the CommandContext.Env
func (c *CommandContext) Getenv(key string) string {
// FIXME: parse c.Env instead
return os.Getenv(key)
}