diff --git a/pkg/commands/info/info.go b/pkg/commands/info/info.go index 91d0e18..b4eace7 100644 --- a/pkg/commands/info/info.go +++ b/pkg/commands/info/info.go @@ -2,7 +2,9 @@ package info import ( "fmt" + "os" "runtime" + "strings" "github.com/apex/log" "github.com/urfave/cli/v2" @@ -17,7 +19,8 @@ func Execute(c *cli.Context) error { return err } - log.Infof("distillery/%s", common.AppVersion.Summary) + log.Info("version information") + log.Infof(" distillery/%s", common.AppVersion.Summary) fmt.Println("") log.Infof("system information") log.Infof(" os: %s", runtime.GOOS) @@ -34,6 +37,14 @@ func Execute(c *cli.Context) error { log.Warnf(" - %s", cfg.BinPath) log.Warnf(" - %s", cfg.GetOptPath()) + path := os.Getenv("PATH") + if !strings.Contains(path, cfg.BinPath) { + fmt.Println("") + log.Warnf("Problem: distillery will not work correctly") + log.Warnf(" - %s is not in your PATH", cfg.BinPath) + fmt.Println("") + } + return nil } diff --git a/pkg/commands/install/source.go b/pkg/commands/install/source.go index 29e1e56..5cd8365 100644 --- a/pkg/commands/install/source.go +++ b/pkg/commands/install/source.go @@ -86,7 +86,7 @@ func NewSource(src string, opts *provider.Options) (provider.ISource, error) { / Repo: parts[1], Version: version, }, nil - case "gitlab": + case source.GitLabSource: return &source.GitLab{ Provider: provider.Provider{Options: opts, OSConfig: detectedOS}, Owner: parts[0], @@ -97,7 +97,7 @@ func NewSource(src string, opts *provider.Options) (provider.ISource, error) { / return nil, fmt.Errorf("invalid install source, expect alias or format of owner/repo or owner/repo@version") } else if len(parts) >= 3 { - if strings.HasPrefix(parts[0], "github") { + if strings.HasPrefix(parts[0], source.GitHubSource) { if parts[1] == source.HashicorpSource { return &source.Hashicorp{ Provider: provider.Provider{Options: opts, OSConfig: detectedOS}, @@ -123,7 +123,7 @@ func NewSource(src string, opts *provider.Options) (provider.ISource, error) { / Repo: parts[2], Version: version, }, nil - } else if strings.HasPrefix(parts[0], "gitlab") { + } else if strings.HasPrefix(parts[0], source.GitLabSource) { return &source.GitLab{ Provider: provider.Provider{Options: opts, OSConfig: detectedOS}, Owner: parts[1], diff --git a/pkg/config/alias.go b/pkg/config/alias.go index 1b10ecc..17f742e 100644 --- a/pkg/config/alias.go +++ b/pkg/config/alias.go @@ -9,9 +9,9 @@ import ( type Aliases map[string]*Alias type Alias struct { - Name string `yaml:"name" toml:"name"` - Version string `yaml:"version" toml:"version"` - Bin string `yaml:"bin" toml:"bin"` + Name string `yaml:"name" toml:"name"` + Version string `yaml:"version" toml:"version"` + Flags map[string]bool `yaml:"flags" toml:"flags"` } func (a *Alias) UnmarshalYAML(unmarshal func(interface{}) error) error { diff --git a/pkg/config/config.go b/pkg/config/config.go index 00d33a7..a8d22fa 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -13,6 +13,7 @@ import ( "github.com/ekristen/distillery/pkg/common" ) +// Config - the configuration for distillery type Config struct { // Path - path to store the configuration files, this path is set by default based on the operating system type // and your user's home directory. Typically, this is set to $HOME/.distillery @@ -40,22 +41,27 @@ type Config struct { Language string `yaml:"language" toml:"language"` } +// GetCachePath - get the cache path func (c *Config) GetCachePath() string { return filepath.Join(c.CachePath, common.NAME) } +// GetMetadataPath - get the metadata path func (c *Config) GetMetadataPath() string { return filepath.Join(c.CachePath, common.NAME, "metadata") } +// GetDownloadsPath - get the downloads path func (c *Config) GetDownloadsPath() string { return filepath.Join(c.CachePath, common.NAME, "downloads") } +// GetOptPath - get the opt path func (c *Config) GetOptPath() string { return filepath.Join(c.Path, "opt") } +// GetAlias - get an alias by name func (c *Config) GetAlias(name string) *Alias { if c.Aliases == nil { return nil @@ -70,6 +76,7 @@ func (c *Config) GetAlias(name string) *Alias { return nil } +// MkdirAll - create all the directories func (c *Config) MkdirAll() error { paths := []string{c.BinPath, c.GetOptPath(), c.CachePath, c.GetMetadataPath(), c.GetDownloadsPath()} diff --git a/pkg/source/gitlab.go b/pkg/source/gitlab.go index f863de2..bcd87e4 100644 --- a/pkg/source/gitlab.go +++ b/pkg/source/gitlab.go @@ -14,6 +14,8 @@ import ( "github.com/ekristen/distillery/pkg/provider" ) +const GitLabSource = "gitlab" + type GitLab struct { provider.Provider @@ -27,7 +29,7 @@ type GitLab struct { } func (s *GitLab) GetSource() string { - return "gitlab" + return GitLabSource } func (s *GitLab) GetOwner() string { return s.Owner