Skip to content

Commit

Permalink
docs: improving docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Nov 11, 2024
1 parent 710f532 commit 006d86c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
13 changes: 12 additions & 1 deletion pkg/commands/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package info

import (
"fmt"
"os"
"runtime"
"strings"

"github.com/apex/log"
"github.com/urfave/cli/v2"
Expand All @@ -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)
Expand All @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/commands/install/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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},
Expand All @@ -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],
Expand Down
6 changes: 3 additions & 3 deletions pkg/config/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()}

Expand Down
4 changes: 3 additions & 1 deletion pkg/source/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/ekristen/distillery/pkg/provider"
)

const GitLabSource = "gitlab"

type GitLab struct {
provider.Provider

Expand All @@ -27,7 +29,7 @@ type GitLab struct {
}

func (s *GitLab) GetSource() string {
return "gitlab"
return GitLabSource
}
func (s *GitLab) GetOwner() string {
return s.Owner
Expand Down

0 comments on commit 006d86c

Please sign in to comment.