Skip to content

Commit

Permalink
Add hint to init command in no local lake exists
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnibs committed Sep 28, 2023
1 parent f662ee1 commit 839449f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli/lakeflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/brimdata/zed/api/client"
"github.com/brimdata/zed/api/client/auth0"
"github.com/brimdata/zed/lake"
"github.com/brimdata/zed/lake/api"
"github.com/brimdata/zed/pkg/storage"
"go.uber.org/zap"
Expand Down Expand Up @@ -73,7 +74,11 @@ func (l *Flags) Open(ctx context.Context) (api.Interface, error) {
}
return api.NewRemoteLake(conn), nil
}
return api.OpenLocalLake(ctx, zap.Must(zap.NewProduction()), uri.String())
lk, err := api.OpenLocalLake(ctx, zap.Must(zap.NewProduction()), uri.String())
if errors.Is(err, lake.ErrNotExist) {
return nil, fmt.Errorf("%w\n(hint: run 'zed init' to initialize lake at this location)", err)
}
return lk, err
}

func (l *Flags) AuthStore() *auth0.Store {
Expand Down
11 changes: 11 additions & 0 deletions cmd/zed/ztests/init-hint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
script: |
export ZED_LAKE=path/to/zed
! zed ls
outputs:
- name: stderr
regexp: |
.* lake does not exist
\(hint: run 'zed init' to initialize lake at this location\)
- name: stdout
data: ""

0 comments on commit 839449f

Please sign in to comment.