Skip to content

Commit 65c4291

Browse files
committed
fix: extractKey missing
1 parent d4f4bd3 commit 65c4291

File tree

3 files changed

+71
-75
lines changed

3 files changed

+71
-75
lines changed

.goreleaser.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,17 @@ builds:
3838

3939
archives:
4040
- id: sohot-archive
41-
builds:
42-
- sohot
41+
builds: [sohot]
4342
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
44-
format_overrides:
45-
- goos: windows
46-
format: zip
47-
format: tar.gz
4843
files:
4944
- README.md
5045
- README_CN.md
5146
- LICENSE
5247
- sohot.toml
48+
rlcp: true
49+
format_overrides:
50+
- goos: windows
51+
rlcp: false
5352

5453
checksum:
5554
name_template: 'checksums.txt'
@@ -108,7 +107,7 @@ changelog:
108107

109108
# Snapshot builds for testing
110109
snapshot:
111-
name_template: "{{ incpatch .Version }}-next"
110+
version_template: "{{ incpatch .Version }}-next"
112111

113112
# Metadata for the release
114113
metadata:

main.go

Lines changed: 65 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,75 @@
11
package main
22

33
import (
4-
"fmt"
5-
"os"
6-
"github.com/rs/zerolog/log"
7-
"sohot/e"
8-
"sohot/version"
9-
"sohot/watch"
10-
"sort"
4+
"fmt"
5+
"os"
6+
"sohot/e"
7+
"sohot/version"
8+
"sohot/watch"
9+
"sort"
10+
"strings"
1111

12-
"github.com/manifoldco/promptui"
12+
"github.com/rs/zerolog/log"
13+
14+
"github.com/manifoldco/promptui"
1315
)
1416

1517
//go:generate go install .
1618
func main() {
17-
var key string
18-
19-
// Check if command line arguments are provided
20-
if len(os.Args) > 1 {
21-
arg := os.Args[1]
22-
23-
// Handle version commands
24-
if arg == "--version" || arg == "-v" || arg == "version" {
25-
buildInfo := version.GetBuildInfo()
26-
fmt.Println(buildInfo.String())
27-
return
28-
}
29-
30-
key = arg
31-
log.Info().Str("profile", key).Msg("Using command line specified profile")
32-
} else {
33-
// No arguments provided, show interactive selection interface
34-
items := make([]string, 0, len(e.V.Run))
35-
for s, run := range e.V.Run {
36-
if run.Only {
37-
s += "#Run only mode"
38-
}
39-
items = append(items, s)
40-
}
41-
sort.Strings(items)
42-
prompt := promptui.Select{
43-
Label: "Select profile",
44-
Items: items,
45-
}
46-
_, result, err := prompt.Run()
19+
var key string
20+
21+
// Check if command line arguments are provided
22+
if len(os.Args) > 1 {
23+
arg := os.Args[1]
24+
25+
// Handle version commands
26+
if arg == "--version" || arg == "-v" || arg == "version" {
27+
buildInfo := version.GetBuildInfo()
28+
fmt.Println(buildInfo.String())
29+
return
30+
}
31+
32+
key = arg
33+
log.Info().Str("profile", key).Msg("Using command line specified profile")
34+
} else {
35+
// No arguments provided, show interactive selection interface
36+
items := make([]string, 0, len(e.V.Run))
37+
for s, run := range e.V.Run {
38+
if run.Only {
39+
s += "#Run only mode"
40+
}
41+
items = append(items, s)
42+
}
43+
sort.Strings(items)
44+
prompt := promptui.Select{
45+
Label: "Select profile",
46+
Items: items,
47+
}
48+
_, result, err := prompt.Run()
4749

48-
if err != nil {
49-
fmt.Printf("Prompt failed %v\n", err)
50-
return
51-
}
52-
key = extractKey(result)
53-
}
54-
55-
// Verify if the profile exists
56-
run, ok := e.V.Run[key]
57-
if !ok {
58-
log.Fatal().Str("profile", key).Msg("Profile not found")
59-
}
60-
61-
// Show version information at startup
62-
buildInfo := version.GetBuildInfo()
63-
log.Info().Str("version", buildInfo.Version).Str("commit", buildInfo.Commit).Msg("Starting SoHot")
64-
65-
watch.Watching(run)
66-
watch.Building(run)
50+
if err != nil {
51+
fmt.Printf("Prompt failed %v\n", err)
52+
return
53+
}
54+
key = extractKey(result)
55+
}
56+
57+
// Verify if the profile exists
58+
run, ok := e.V.Run[key]
59+
if !ok {
60+
log.Fatal().Str("profile", key).Msg("Profile not found")
61+
}
62+
63+
// Show version information at startup
64+
buildInfo := version.GetBuildInfo()
65+
log.Info().Str("version", buildInfo.Version).Str("commit", buildInfo.Commit).Msg("Starting SoHot")
66+
67+
watch.Watching(run)
68+
watch.Building(run)
69+
}
70+
func extractKey(result string) string {
71+
if idx := strings.Index(result, "#"); idx != -1 {
72+
return result[:idx]
73+
}
74+
return result
6775
}

utils.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)