func fillProfileRuntime(commonCfg *torcx.CommonConfig) (*torcx.ProfileConfig, error) {
	var (
		lowerProfileNames []string
		upperProfileName  string
		curProfilePath    string
		nextProfile       string
	)
	if commonCfg == nil {
		return nil, errors.New("missing common configuration")
	}
	upn, lpn, err := torcx.CurrentProfileNames()
	if err == nil {
		lowerProfileNames = lpn
		upperProfileName = upn
	}
	cpp, err := torcx.CurrentProfilePath()
	if err == nil {
		curProfilePath = cpp
	}
	nextProfile, err = commonCfg.NextProfileName()
	if err != nil {
		nextProfile = ""
	}
	logrus.WithFields(logrus.Fields{
		"lower profiles": lpn,
		"upper profile":  upperProfileName,
		"next profile":   nextProfile,
	}).Debug("profile configuration parsed")
	return &torcx.ProfileConfig{
		CommonConfig:       *commonCfg,
		LowerProfileNames:  lowerProfileNames,
		UserProfileName:    upperProfileName,
		CurrentProfilePath: curProfilePath,
		NextProfile:        nextProfile,
	}, nil
}
fillProfileRuntime generates the runtime config for profile subcommands,
starting from system-wide state and config
package cli
import (
	"github.com/pkg/errors"
	"github.com/sirupsen/logrus"
	"github.com/spf13/cobra"
	"github.com/coreos/torcx/internal/torcx"
)
var (
	cmdProfile = &cobra.Command{
		Use:   "profile [command]",
		Short: "Operate on local profile(s)",
		Long:  `This subcommand operates on local profile(s).`,
	}
)
func init() {
	TorcxCmd.AddCommand(cmdProfile)
}