-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: barry 2025-01-04 22:19:39 * refactor(tagcmd): improve tag generation logic and exit handling * chore: remove duplicate linux_amd64 build target * fix: barry 2025-01-05 09:56:33 * fix: barry 2025-01-05 10:00:42 * fix: barry 2025-01-05 10:01:13 * refactor: move config-related code to configs package * fix: barry 2025-01-05 10:18:32 * refactor: improve logging and UI message clarity * feat: add env command and config support * fix: barry 2025-01-05 11:00:37 * fix: barry 2025-01-05 11:05:09
- Loading branch information
Showing
13 changed files
with
154 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
package bootstrap | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/adrg/xdg" | ||
"github.com/pubgo/fastcommit/configs" | ||
"github.com/pubgo/fastcommit/utils" | ||
"github.com/pubgo/funk/assert" | ||
) | ||
|
||
type ConfigProvider struct { | ||
Version *configs.Version `yaml:"version"` | ||
OpenaiConfig *utils.OpenaiConfig `yaml:"openai"` | ||
} | ||
|
||
var configPath = assert.Exit1(xdg.ConfigFile("fastcommit/config.yaml")) | ||
var branchName = assert.Exit1(utils.RunOutput("git", "rev-parse", "--abbrev-ref", "HEAD")) | ||
|
||
//go:embed default.yaml | ||
var defaultConfig []byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package envcmd | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pubgo/fastcommit/configs" | ||
"github.com/pubgo/funk/assert" | ||
"github.com/pubgo/funk/pretty" | ||
"github.com/pubgo/funk/recovery" | ||
"github.com/samber/lo" | ||
"github.com/urfave/cli/v3" | ||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
func New() *cli.Command { | ||
return &cli.Command{ | ||
Name: "env", | ||
Usage: "show all envs", | ||
Action: func(ctx context.Context, command *cli.Command) error { | ||
defer recovery.Exit() | ||
var envData = configs.GetEnvConfig() | ||
var envMap = make(map[string]*configs.EnvConfig) | ||
assert.Must(yaml.Unmarshal(envData, &envMap)) | ||
for name := range envMap { | ||
envMap[name].Name = name | ||
} | ||
|
||
pretty.Println(lo.Values(envMap)) | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
package configs | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/adrg/xdg" | ||
"github.com/pubgo/fastcommit/utils" | ||
"github.com/pubgo/funk/assert" | ||
) | ||
|
||
type EnvConfig struct { | ||
Description string `yaml:"description"` | ||
Default string `yaml:"default"` | ||
Name string `yaml:"name"` | ||
Required bool `yaml:"required"` | ||
} | ||
|
||
type Config struct { | ||
BranchName string | ||
} | ||
|
||
type Version struct { | ||
Name string `yaml:"name"` | ||
} | ||
|
||
var configPath = assert.Exit1(xdg.ConfigFile("fastcommit/config.yaml")) | ||
var branchName = assert.Exit1(utils.RunOutput("git", "rev-parse", "--abbrev-ref", "HEAD")) | ||
|
||
//go:embed default.yaml | ||
var defaultConfig []byte | ||
|
||
//go:embed env.yaml | ||
var envConfig []byte | ||
|
||
func GetConfigPath() string { | ||
return configPath | ||
} | ||
|
||
func GetBranchName() string { | ||
return branchName | ||
} | ||
|
||
func GetDefaultConfig() []byte { | ||
return defaultConfig | ||
} | ||
|
||
func GetEnvConfig() []byte { | ||
return envConfig | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
OPENAI_API_KEY: | ||
description: "OpenAI API Key" | ||
required: true | ||
OPENAI_BASE_URL: | ||
description: "OpenAI Base URL" | ||
default: "https://api.deepseek.com/v1" | ||
OPENAI_MODEL: | ||
description: "OpenAI Model" | ||
default: "deepseek-chat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters