made some metadata of the program dynamic
This commit is contained in:
parent
0b7de76874
commit
68c89de1a4
3
internal/cache/cache.go
vendored
3
internal/cache/cache.go
vendored
@ -10,6 +10,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"gitea.elara.ws/Hazel/transfem-startpage/internal/utils"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ func getCacheDir() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
baseDir = "/tmp"
|
baseDir = "/tmp"
|
||||||
}
|
}
|
||||||
cacheDir := filepath.Join(baseDir, "startpage")
|
cacheDir := filepath.Join(baseDir, utils.Name)
|
||||||
err = os.MkdirAll(cacheDir, 0o755)
|
err = os.MkdirAll(cacheDir, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"gitea.elara.ws/Hazel/transfem-startpage/internal/utils"
|
||||||
"github.com/TwiN/go-color"
|
"github.com/TwiN/go-color"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,8 +23,8 @@ type Argument struct {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
var HelpHeader = `This is the help page of transfem-startpage.
|
var HelpHeader = `This is the help page of ` + utils.Name + `.
|
||||||
` + color.Purple + `transfem-startpage {program} {...args}` + color.Reset + `
|
` + color.Purple + utils.BinaryName + ` {program} {...args}` + color.Reset + `
|
||||||
The following Programs are available:`
|
The following Programs are available:`
|
||||||
var Programs = []Program{
|
var Programs = []Program{
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gitea.elara.ws/Hazel/transfem-startpage/internal/utils"
|
||||||
"github.com/TwiN/go-color"
|
"github.com/TwiN/go-color"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ func specificHelp(programName string) error {
|
|||||||
fmt.Println(color.Bold + "MAN PAGE FOR " + strings.ToUpper(programName) + color.Reset)
|
fmt.Println(color.Bold + "MAN PAGE FOR " + strings.ToUpper(programName) + color.Reset)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
fmt.Println(color.Purple + "transfem-startpage " + programName + color.Reset + getArgumentString(program.Arguments))
|
fmt.Println(color.Purple + utils.BinaryName + " " + programName + color.Reset + getArgumentString(program.Arguments))
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
fmt.Println(color.Bold + "arguments" + color.Reset)
|
fmt.Println(color.Bold + "arguments" + color.Reset)
|
||||||
|
@ -11,7 +11,7 @@ const endpoint = "https://diyhrt.market/api/listings"
|
|||||||
|
|
||||||
func GetListings(apiKey string) ([]Listing, error) {
|
func GetListings(apiKey string) ([]Listing, error) {
|
||||||
if apiKey == "" {
|
if apiKey == "" {
|
||||||
return nil, errors.New("API_KEY key not set. Set it as env or in DiyHrt.ApiKey")
|
return nil, errors.New("diyhrt API_KEY key not set. Set it as env or in DiyHrt.ApiKey")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create HTTP client
|
// Create HTTP client
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"gitea.elara.ws/Hazel/transfem-startpage/internal/diyhrt"
|
"gitea.elara.ws/Hazel/transfem-startpage/internal/diyhrt"
|
||||||
|
"gitea.elara.ws/Hazel/transfem-startpage/internal/utils"
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ func (rc *Config) ScanForConfigFile(profile string) error {
|
|||||||
|
|
||||||
baseDir, cacheDirErr := os.UserConfigDir()
|
baseDir, cacheDirErr := os.UserConfigDir()
|
||||||
if cacheDirErr == nil {
|
if cacheDirErr == nil {
|
||||||
configFile := filepath.Join(baseDir, "startpage", profileFile)
|
configFile := filepath.Join(baseDir, utils.Name, profileFile)
|
||||||
|
|
||||||
if err := rc.LoadConfigFile(configFile); !errors.Is(err, os.ErrNotExist) {
|
if err := rc.LoadConfigFile(configFile); !errors.Is(err, os.ErrNotExist) {
|
||||||
return err
|
return err
|
||||||
|
6
internal/utils/meta.go
Normal file
6
internal/utils/meta.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
var Name = "transfem-startpage"
|
||||||
|
var BinaryName = os.Args[0]
|
@ -1 +1 @@
|
|||||||
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1exit status 1
|
Loading…
x
Reference in New Issue
Block a user