Skip to content

Commit

Permalink
Add Comments; Switch Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinGimbel committed May 2, 2018
1 parent f553831 commit 7911f4f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
39 changes: 32 additions & 7 deletions lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,71 @@ package lib
import "os"

var (
outdir = os.Getenv("HOME") + "/.license/"
outfile = outdir + "license.json"
httpsource = "http://osl.kevin.codes/"
version string
buildDate string
commit string
outdir = os.Getenv("HOME") + "/.license/"
outfile = outdir + "license.json"
httpsource = "http://osl.kevingimbel.com/"
version string
buildDate string
commit string
config Config
)

// SetConfig sets a value to the (global) configuration object
func SetConfig(k, v string) {
switch k {
case "name":
config.Name = v
case "year":
config.Year = v
}
}

// GetConfig retrieves the global configuration
func GetConfig() Config {
return config
}

// GetVersion returns the version of license (set during build)
func GetVersion() string {
return version
}

// GetCommit returns the commit number (set during build)
func GetCommit() string {
return commit
}

// GetBuildDate returns the build date (set during build)
func GetBuildDate() string {
return buildDate
}

// GetOutputFilePath returns the name (string) of the output file.
func GetOutputFilePath() string {
return outfile
}

// GetOutputPath returns the output path for the license CLI config directory
func GetOutputPath() string {
return outdir
}

// GetBaseURL returns the base URL or HTTP Source from which to download files
func GetBaseURL() string {
return httpsource
}

// GetSingleLicenseURL returns the URL to the single-view from where to download license files
func GetSingleLicenseURL() string {
return httpsource + "licenses/"
}

// GetUpdateURL returns the URL to the API endpoint from which a overview of all licenses is loaded
func GetUpdateURL() string {
return httpsource + "licenses/"
}

// GetUserAgentHeader returns the User-Agent header with which the CLI tool identifies itself
func GetUserAgentHeader() string {
return "license v" + version
}
}
11 changes: 9 additions & 2 deletions lib/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package lib

// OSLJSONFormat represents the JSON structure of the API for license overviews
type OSLJSONFormat struct {
Name string `json:"name"`
Link string `json:"link"`
ID string `json:"id"`
}
ID string `json:"id"`
}

// Config represents the configuration for text replacements inside license templates
type Config struct {
Name string
Year string
}

0 comments on commit 7911f4f

Please sign in to comment.