Skip to content

Commit c367e53

Browse files
committed
v0.0.10: refine lcl command
1 parent 695de14 commit c367e53

32 files changed

Lines changed: 433 additions & 696 deletions

api/api.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func getServicePath(orgSlug, serviceSlug string) string {
228228
func (s *Session) GetService(ctx context.Context, orgSlug, serviceSlug string) (*Service, error) {
229229
var svc Service
230230
if err := s.get(ctx, getServicePath(orgSlug, serviceSlug), &svc); err != nil {
231-
if err == NotFoundErr {
231+
if errors.Is(err, NotFoundErr) {
232232
return nil, nil
233233
}
234234
return nil, err
@@ -248,7 +248,11 @@ func (s *Session) get(ctx context.Context, path string, out any) error {
248248
return err
249249
}
250250
if res.StatusCode != http.StatusOK {
251-
return StatusCodeError(res.StatusCode)
251+
var errorsRes *Error
252+
if err = json.NewDecoder(res.Body).Decode(&errorsRes); err != nil {
253+
return err
254+
}
255+
return fmt.Errorf("%w: %s", StatusCodeError(res.StatusCode), errorsRes.Title)
252256
}
253257
return json.NewDecoder(res.Body).Decode(out)
254258
}
@@ -274,7 +278,11 @@ func (s *Session) post(ctx context.Context, path string, in, out any) error {
274278
return err
275279
}
276280
if res.StatusCode != http.StatusOK {
277-
return fmt.Errorf("unexpected response code: %d", res.StatusCode)
281+
var errorsRes *Error
282+
if err = json.NewDecoder(res.Body).Decode(&errorsRes); err != nil {
283+
return err
284+
}
285+
return fmt.Errorf("%w: %s", StatusCodeError(res.StatusCode), errorsRes.Title)
278286
}
279287
return json.NewDecoder(res.Body).Decode(out)
280288
}
@@ -351,4 +359,4 @@ type StatusCodeError int
351359
const NotFoundErr = StatusCodeError(http.StatusNotFound)
352360

353361
func (err StatusCodeError) StatusCode() int { return int(err) }
354-
func (err StatusCodeError) Error() string { return fmt.Sprintf("unexpected response code: %d", err) }
362+
func (err StatusCodeError) Error() string { return fmt.Sprintf("unexpected %d status response", err) }

auth/auth_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"github.com/anchordotdev/cli/api/apitest"
99
)
1010

11+
var (
12+
_ = flag.Bool("update", false, "ignored")
13+
)
14+
1115
var srv = &apitest.Server{
1216
Host: "api.anchor.lcl.host",
1317
RootDir: "../..",

auth/models/signin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type SignInChecker struct {
7777
}
7878

7979
func (m *SignInChecker) Init() tea.Cmd {
80-
m.spinner = ui.Spinner()
80+
m.spinner = ui.WaitingSpinner()
8181

8282
return m.spinner.Tick
8383
}

auth/whoami_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestWhoAmI(t *testing.T) {
3434
cfg.Keyring.MockMode = true
3535

3636
var err error
37-
if cfg.API.Token, err = srv.GeneratePAT("example@example.com"); err != nil {
37+
if cfg.API.Token, err = srv.GeneratePAT("anky@anchor.dev"); err != nil {
3838
t.Fatal(err)
3939
}
4040

@@ -47,7 +47,7 @@ func TestWhoAmI(t *testing.T) {
4747
t.Fatal(err)
4848
}
4949

50-
if want, got := "Hello example@example.com!\n", buf.String(); want != got {
50+
if want, got := "Hello anky@anchor.dev!\n", buf.String(); want != got {
5151
t.Errorf("want output %q, got %q", want, got)
5252
}
5353
})

cert/models/provision.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Provision struct {
1818
}
1919

2020
func (m *Provision) Init() tea.Cmd {
21-
m.spinner = ui.Spinner()
21+
m.spinner = ui.WaitingSpinner()
2222

2323
return m.spinner.Tick
2424
}

cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Config struct {
2525
Subdomain string `desc:"Subdomain for lcl.host diagnostic service." flag:"subdomain" env:"SUBDOMAIN" json:"subdomain" toml:"subdomain"`
2626

2727
DiagnosticAddr string `default:":4433" desc:"Local server address" flag:"addr,a" env:"ADDR" json:"address" toml:"address"`
28-
LclHostURL string `default:"https://lcl.host" env:"LCL_HOST_URL"`
28+
LclHostURL string `default:"https://lcl.anchor.systems" env:"LCL_HOST_URL"`
2929

3030
Detect struct {
3131
PackageManager string `desc:"Package manager to use for integrating Anchor." flag:"package-manager" env:"PACKAGE_MANAGER" json:"package_manager" toml:"package-manager"`

cmd/anchor/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ var (
9090
},
9191
},
9292
{
93-
UI: trust.Sync{Config: cfg}.UI(),
93+
UI: trust.Command{Config: cfg}.UI(),
9494

9595
Name: "trust",
9696
Use: "trust [org[/realm[/ca]]]",

command.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ func (c *Command) Execute(ctx context.Context, cfg *Config) error {
5353

5454
func (c *Command) cobraCommand(ctx context.Context, cfgv reflect.Value) *cobra.Command {
5555
cmd := &cobra.Command{
56-
Use: c.Use,
57-
Short: c.Short,
58-
Long: c.Long,
59-
GroupID: c.Group,
60-
Hidden: c.Hidden,
56+
Use: c.Use,
57+
Short: c.Short,
58+
Long: c.Long,
59+
GroupID: c.Group,
60+
Hidden: c.Hidden,
61+
SilenceUsage: true,
6162
}
6263

6364
if c.Preflight != nil {

detection/detection_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
var (
1111
_ = flag.Bool("prism-verbose", false, "ignored")
1212
_ = flag.Bool("prism-proxy", false, "ignored")
13+
_ = flag.Bool("update", false, "ignored")
1314
)
1415

1516
func TestScore_String(t *testing.T) {

diagnostic/server_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
var (
1717
_ = flag.Bool("prism-verbose", false, "ignored")
1818
_ = flag.Bool("prism-proxy", false, "ignored")
19+
_ = flag.Bool("update", false, "ignored")
1920
)
2021

2122
func TestServerSupportsDualProtocols(t *testing.T) {

0 commit comments

Comments
 (0)