func RetrieveConfig(
	ctx context.Context,
) (*Config, error) {
	path, err := ConfigPath(ctx)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if _, err := os.Stat(*path); os.IsNotExist(err) {
		return nil, nil
	}
	raw, err := ioutil.ReadFile(*path)
	if err != nil {
		return nil, errors.Trace(err)
	}
	var c Config
	err = json.Unmarshal(raw, &c)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &c, nil
}
RetrieveConfig retrieves the current user config by reading ConfigPath.
package cli
import (
	"context"
	"encoding/json"
	"io/ioutil"
	"os"
	"path/filepath"
	homedir "github.com/mitchellh/go-homedir"
	"github.com/spolu/warp/lib/errors"
	"github.com/spolu/warp/lib/token"
)
type Credentials struct {
	User   string `json:"user"`
	Secret string `json:"secret"`
}
type Config struct {
	Credentials Credentials `json:"credentials"`
}
func ConfigPath(
	ctx context.Context,
) (*string, error) {
	path, err := homedir.Expand(
		"~/.warp/config.json",
	)
	if err != nil {
		return nil, errors.Trace(err)
	}
	err = os.MkdirAll(filepath.Dir(path), 0777)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return &path, nil
}