Skip to content

Commit 39329f6

Browse files
committed
v0.0.25: misc cleanup and fixes
1 parent 14a61f0 commit 39329f6

File tree

27 files changed

+105
-118
lines changed

27 files changed

+105
-118
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ jobs:
138138
- shell: bash
139139
run: |
140140
cp cmd/anchor/dist/windows/anchor.${{ env.RELEASE_VERSION }}.nupkg ./
141+
- uses: actions/upload-artifact@v4
142+
with:
143+
name: anchor.${{ env.RELEASE_VERSION }}.nupkg
144+
overwrite: true
145+
path: cmd/anchor/dist/windows/anchor.${{ env.RELEASE_VERSION }}.nupkg
141146

142147
- shell: pwsh
143148
run: |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Available via [Chocolatey][] or as a downloadable binary from the [releases page
5252

5353
Install:
5454
```
55-
chocolatey install anchor --version=0.0.23
55+
chocolatey install anchor --version=0.0.22
5656
```
5757

5858
### Install from source

api/api.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"github.com/anchordotdev/cli"
1919
"github.com/anchordotdev/cli/keyring"
20-
"github.com/anchordotdev/cli/version"
2120
"golang.org/x/exp/slices"
2221
)
2322

@@ -370,7 +369,7 @@ type userAgentSetter struct {
370369
}
371370

372371
func (s userAgentSetter) RoundTrip(req *http.Request) (*http.Response, error) {
373-
req.Header.Set("User-Agent", version.UserAgent())
372+
req.Header.Set("User-Agent", cli.UserAgent())
374373

375374
return s.RoundTripper.RoundTrip(req)
376375
}

auth/models/whoami.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (m *WhoAmIChecker) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
3939
switch msg := msg.(type) {
4040
case UserWhoAmIMsg:
4141
m.whoami = string(msg)
42-
return m, tea.Quit
42+
return m, nil
4343
}
4444

4545
var cmd tea.Cmd

auth/testdata/TestWhoAmI/signed-in.golden

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
# Identify Current Anchor.dev Account `anchor auth whoami`
33
─── WhoAmIChecker ──────────────────────────────────────────────────────────────
44
# Identify Current Anchor.dev Account `anchor auth whoami`
5-
* Identifying Anchor.dev account… *
5+
* Identifying Anchor.dev account… ⠋
6+
─── WhoAmIChecker ──────────────────────────────────────────────────────────────
7+
# Identify Current Anchor.dev Account `anchor auth whoami`
8+
- Identified Anchor.dev account: [email protected]

cli.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,41 @@ package cli
22

33
import (
44
"context"
5+
"fmt"
6+
"runtime"
57

68
"github.com/anchordotdev/cli/ui"
79
"github.com/spf13/cobra"
810
)
911

12+
var Version = struct {
13+
Version, Commit, Date string
14+
15+
Os, Arch string
16+
}{
17+
Version: "dev",
18+
Commit: "none",
19+
Date: "unknown",
20+
Os: runtime.GOOS,
21+
Arch: runtime.GOARCH,
22+
}
23+
24+
func IsDevVersion() bool {
25+
return Version.Version == "dev"
26+
}
27+
28+
func UserAgent() string {
29+
return "Anchor CLI " + VersionString()
30+
}
31+
32+
func ReleaseTagName() string {
33+
return fmt.Sprintf("v%s", Version.Version)
34+
}
35+
36+
func VersionString() string {
37+
return fmt.Sprintf("%s (%s/%s) Commit: %s BuildDate: %s", Version.Version, Version.Os, Version.Arch, Version.Commit, Version.Date)
38+
}
39+
1040
type Config struct {
1141
JSON bool `desc:"Only print JSON output to STDOUT." flag:"json,j" env:"JSON_OUTPUT" toml:"json-output"`
1242
NonInteractive bool `desc:"Run without ever asking for user input." flag:"non-interactive,n" env:"NON_INTERACTIVE" toml:"non-interactive"`

cmd.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,20 @@ func NewCmd[T UIer](parent *cobra.Command, name string, fn func(*cobra.Command))
245245
panic(err)
246246
}
247247

248-
cmd.RunE = func(cmd *cobra.Command, _ []string) error {
248+
cmd.RunE = func(cmd *cobra.Command, args []string) error {
249249
cfg := ConfigFromCmd(cmd)
250250
if cfg.Test.SkipRunE {
251251
return nil
252252
}
253253

254+
var t T
255+
256+
switch any(t).(type) {
257+
case ShowHelp:
258+
cmd.HelpFunc()(cmd, args)
259+
return nil
260+
}
261+
254262
ctx, cancel := context.WithCancelCause(cmd.Context())
255263
defer cancel(nil)
256264

@@ -266,7 +274,6 @@ func NewCmd[T UIer](parent *cobra.Command, name string, fn func(*cobra.Command))
266274
errc <- err
267275
}()
268276

269-
var t T
270277
if err := t.UI().RunTUI(ctx, drv); err != nil && err != context.Canceled {
271278
prg.Quit()
272279

cmd/anchor/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ var (
2121

2222
func init() {
2323
if version != "" {
24-
versionpkg.Set(version, commit, date)
24+
cli.Version.Commit = commit
25+
cli.Version.Date = date
26+
cli.Version.Version = version
2527
}
2628
cli.CmdRoot.PersistentPreRunE = versionpkg.VersionCheck
2729
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ require (
1919
github.com/muesli/termenv v0.15.2
2020
github.com/oapi-codegen/runtime v1.1.1
2121
github.com/spf13/cobra v1.8.0
22-
github.com/spf13/pflag v1.0.5
2322
github.com/stretchr/testify v1.8.4
2423
github.com/zalando/go-keyring v0.2.4
2524
golang.org/x/crypto v0.21.0
@@ -64,6 +63,7 @@ require (
6463
github.com/rivo/uniseg v0.4.7 // indirect
6564
github.com/rogpeppe/go-internal v1.10.0 // indirect
6665
github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect
66+
github.com/spf13/pflag v1.0.5 // indirect
6767
golang.org/x/mod v0.16.0 // indirect
6868
golang.org/x/net v0.23.0 // indirect
6969
golang.org/x/oauth2 v0.16.0 // indirect

lcl/config_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,6 @@ func TestLclConfig(t *testing.T) {
112112
t.Skip("diagnostic unsupported in mock mode")
113113
}
114114

115-
teatest.WaitFor(
116-
t, drv.Out,
117-
func(bts []byte) bool {
118-
if len(errc) > 0 {
119-
t.Fatal(<-errc)
120-
}
121-
122-
expect := "Entered hello-world.lcl.host domain for lcl.host diagnostic certificate."
123-
return bytes.Contains(bts, []byte(expect))
124-
},
125-
teatest.WithCheckInterval(time.Millisecond*100),
126-
teatest.WithDuration(time.Second*3),
127-
)
128-
129115
teatest.WaitFor(
130116
t, drv.Out,
131117
func(bts []byte) bool {

0 commit comments

Comments
 (0)