Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set bazel workspace root for the bazel query verbs #128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/aspect/aquery/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
deps = [
"//pkg/aspect/aquery",
"//pkg/bazel",
"//pkg/interceptors",
"//pkg/ioutils",
"@com_github_spf13_cobra//:cobra",
],
Expand Down
17 changes: 14 additions & 3 deletions cmd/aspect/aquery/aquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ Not licensed for re-use
package aquery

import (
"context"

"github.com/spf13/cobra"

"aspect.build/cli/pkg/aspect/aquery"
"aspect.build/cli/pkg/bazel"
"aspect.build/cli/pkg/interceptors"
"aspect.build/cli/pkg/ioutils"
)

Expand All @@ -19,13 +22,21 @@ func NewDefaultAQueryCmd() *cobra.Command {
}

func NewAQueryCommand(streams ioutils.Streams, bzl bazel.Bazel) *cobra.Command {
q := aquery.New(streams, bzl, true)

cmd := &cobra.Command{
Use: "aquery",
Short: "Executes an aquery.",
Long: "Executes a query language expression over a specified subgraph of the build dependency graph using aquery.",
RunE: q.Run,
RunE: interceptors.Run(
[]interceptors.Interceptor{
interceptors.WorkspaceRootInterceptor(),
},
func(ctx context.Context, cmd *cobra.Command, args []string) (exitErr error) {
workspaceRoot := ctx.Value(interceptors.WorkspaceRootKey).(string)
bzl.SetWorkspaceRoot(workspaceRoot)
q := aquery.New(streams, bzl, true)
return q.Run(cmd, args)
},
),
}

return cmd
Expand Down
1 change: 1 addition & 0 deletions cmd/aspect/cquery/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
deps = [
"//pkg/aspect/cquery",
"//pkg/bazel",
"//pkg/interceptors",
"//pkg/ioutils",
"@com_github_spf13_cobra//:cobra",
],
Expand Down
17 changes: 14 additions & 3 deletions cmd/aspect/cquery/cquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ Not licensed for re-use
package cquery

import (
"context"

"github.com/spf13/cobra"

"aspect.build/cli/pkg/aspect/cquery"
"aspect.build/cli/pkg/bazel"
"aspect.build/cli/pkg/interceptors"
"aspect.build/cli/pkg/ioutils"
)

Expand All @@ -19,13 +22,21 @@ func NewDefaultCQueryCmd() *cobra.Command {
}

func NewCQueryCommand(streams ioutils.Streams, bzl bazel.Bazel) *cobra.Command {
q := cquery.New(streams, bzl, true)

cmd := &cobra.Command{
Use: "cquery",
Short: "Executes a cquery.",
Long: "Executes a query language expression over a specified subgraph of the build dependency graph using cquery.",
RunE: q.Run,
RunE: interceptors.Run(
[]interceptors.Interceptor{
interceptors.WorkspaceRootInterceptor(),
},
func(ctx context.Context, cmd *cobra.Command, args []string) (exitErr error) {
workspaceRoot := ctx.Value(interceptors.WorkspaceRootKey).(string)
bzl.SetWorkspaceRoot(workspaceRoot)
q := cquery.New(streams, bzl, true)
return q.Run(cmd, args)
},
),
}

return cmd
Expand Down
1 change: 1 addition & 0 deletions cmd/aspect/query/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_library(
deps = [
"//pkg/aspect/query",
"//pkg/bazel",
"//pkg/interceptors",
"//pkg/ioutils",
"@com_github_spf13_cobra//:cobra",
],
Expand Down
17 changes: 14 additions & 3 deletions cmd/aspect/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ Not licensed for re-use
package query

import (
"context"

"github.com/spf13/cobra"

"aspect.build/cli/pkg/aspect/query"
"aspect.build/cli/pkg/bazel"
"aspect.build/cli/pkg/interceptors"
"aspect.build/cli/pkg/ioutils"
)

Expand All @@ -19,13 +22,21 @@ func NewDefaultQueryCmd() *cobra.Command {
}

func NewQueryCommand(streams ioutils.Streams, bzl bazel.Bazel) *cobra.Command {
q := query.New(streams, bzl, true)

cmd := &cobra.Command{
Use: "query",
Short: "Executes a dependency graph query.",
Long: "Executes a query language expression over a specified subgraph of the build dependency graph.",
RunE: q.Run,
RunE: interceptors.Run(
[]interceptors.Interceptor{
interceptors.WorkspaceRootInterceptor(),
},
func(ctx context.Context, cmd *cobra.Command, args []string) (exitErr error) {
workspaceRoot := ctx.Value(interceptors.WorkspaceRootKey).(string)
bzl.SetWorkspaceRoot(workspaceRoot)
q := query.New(streams, bzl, true)
return q.Run(cmd, args)
},
),
}

return cmd
Expand Down