@@ -2,62 +2,43 @@ package bootstrap
2
2
3
3
import (
4
4
"log/slog"
5
- "os"
6
5
7
6
_ "github.com/adrg/xdg"
8
7
_ "github.com/charmbracelet/bubbletea"
9
8
"github.com/pubgo/dix"
10
- "github.com/pubgo/dix/dix_internal"
9
+ "github.com/pubgo/funk/config"
10
+ "github.com/pubgo/funk/log"
11
+ "github.com/pubgo/funk/recovery"
12
+ _ "github.com/sashabaranov/go-openai"
13
+
14
+ "github.com/pubgo/fastcommit/cmds/configcmd"
11
15
"github.com/pubgo/fastcommit/cmds/envcmd"
12
16
"github.com/pubgo/fastcommit/cmds/fastcommit"
17
+ "github.com/pubgo/fastcommit/cmds/historycmd"
13
18
"github.com/pubgo/fastcommit/cmds/tagcmd"
19
+ "github.com/pubgo/fastcommit/cmds/upgradecmd"
14
20
"github.com/pubgo/fastcommit/cmds/versioncmd"
15
21
"github.com/pubgo/fastcommit/configs"
16
22
"github.com/pubgo/fastcommit/utils"
17
- "github.com/pubgo/funk/assert"
18
- "github.com/pubgo/funk/config"
19
- "github.com/pubgo/funk/pathutil"
20
- "github.com/pubgo/funk/recovery"
21
- "github.com/pubgo/funk/typex"
22
- "github.com/rs/zerolog"
23
- _ "github.com/sashabaranov/go-openai"
24
- "gopkg.in/yaml.v3"
25
23
)
26
24
27
- func Main () {
25
+ func Main (ver string ) {
28
26
defer recovery .Exit ()
29
27
30
- slog .Info ("config path" , "path" , configs .GetConfigPath ())
31
- typex .DoBlock (func () {
32
- if pathutil .IsNotExist (configs .GetConfigPath ()) {
33
- assert .Must (os .WriteFile (configs .GetConfigPath (), configs .GetDefaultConfig (), 0644 ))
34
- return
35
- }
36
-
37
- var cfg ConfigProvider
38
- config .LoadFromPath (& cfg , configs .GetConfigPath ())
39
-
40
- var defaultCfg ConfigProvider
41
- assert .Exit (yaml .Unmarshal (configs .GetDefaultConfig (), & defaultCfg ))
42
- if cfg .Version == nil || cfg .Version .Name == "" || defaultCfg .Version .Name != cfg .Version .Name {
43
- assert .Exit (os .WriteFile (configs .GetConfigPath (), configs .GetDefaultConfig (), 0644 ))
44
- }
45
- })
28
+ slog .SetDefault (slog .New (log .NewSlog (log .GetLogger ("fastcommit" ))))
46
29
47
- config .SetConfigPath (configs .GetConfigPath ())
48
- dix_internal .SetLogLevel (zerolog .InfoLevel )
30
+ initConfig ()
49
31
50
32
var di = dix .New (dix .WithValuesNull ())
51
33
di .Provide (versioncmd .New )
52
- di .Provide (func () * configs.Config {
53
- return & configs.Config {
54
- BranchName : configs .GetBranchName (),
55
- }
56
- })
34
+ di .Provide (upgradecmd .New )
35
+ di .Provide (configs .New )
57
36
di .Provide (tagcmd .New )
58
37
di .Provide (config .Load [ConfigProvider ])
59
38
di .Provide (utils .NewOpenaiClient )
60
39
di .Provide (envcmd .New )
61
- di .Provide (fastcommit .New )
40
+ di .Provide (historycmd .New )
41
+ di .Provide (fastcommit .New (ver ))
42
+ di .Provide (configcmd .New )
62
43
di .Inject (func (cmd * fastcommit.Command ) { cmd .Run () })
63
44
}
0 commit comments