forked from databricks/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (29 loc) · 799 Bytes
/
main.go
File metadata and controls
33 lines (29 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"context"
"os"
"path/filepath"
"strings"
"github.com/databricks/cli/cmd"
"github.com/databricks/cli/cmd/pipelines"
"github.com/databricks/cli/cmd/root"
"github.com/spf13/cobra"
)
// If invoked as 'pipelines' (or 'pipelines.exe' on Windows), returns pipelines-specific commands,
// otherwise returns the databricks CLI commands. This is used to allow the same
// binary to be used for both pipelines and databricks CLI commands.
func getCommand(ctx context.Context) *cobra.Command {
invokedAs := filepath.Base(os.Args[0])
if strings.HasPrefix(invokedAs, "pipelines") {
return pipelines.New(ctx)
}
return cmd.New(ctx)
}
func main() {
ctx := context.Background()
command := getCommand(ctx)
err := root.Execute(ctx, command)
if err != nil {
os.Exit(1)
}
}