2023-11-17 12:47:37 +00:00
|
|
|
package labs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/databricks/cli/cmd/labs/project"
|
|
|
|
"github.com/databricks/cli/libs/cmdio"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newShowCommand() *cobra.Command {
|
|
|
|
return &cobra.Command{
|
|
|
|
Use: "show NAME",
|
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
Short: "Shows information about the project",
|
|
|
|
Annotations: map[string]string{
|
|
|
|
"template": cmdio.Heredoc(`
|
|
|
|
Name: {{.name}}
|
|
|
|
Description: {{.description}}
|
|
|
|
Python: {{.is_python}}
|
|
|
|
|
|
|
|
Folders:
|
|
|
|
- lib: {{.lib_dir}}
|
|
|
|
- cache: {{.cache_dir}}
|
|
|
|
- config: {{.config_dir}}
|
|
|
|
|
|
|
|
`),
|
|
|
|
},
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
ctx := cmd.Context()
|
|
|
|
installed, err := project.Installed(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if len(installed) == 0 {
|
|
|
|
return fmt.Errorf("no projects found")
|
|
|
|
}
|
|
|
|
name := args[0]
|
|
|
|
for _, v := range installed {
|
2023-11-29 19:08:27 +00:00
|
|
|
isDev := name == "." && v.IsDeveloperMode()
|
2023-11-17 12:47:37 +00:00
|
|
|
isMatch := name == v.Name
|
|
|
|
if !(isDev || isMatch) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
return cmdio.Render(ctx, map[string]any{
|
|
|
|
"name": v.Name,
|
|
|
|
"description": v.Description,
|
2023-11-29 19:08:27 +00:00
|
|
|
"cache_dir": v.CacheDir(),
|
|
|
|
"config_dir": v.ConfigDir(),
|
|
|
|
"lib_dir": v.EffectiveLibDir(),
|
|
|
|
"is_python": v.IsPythonProject(),
|
2023-11-17 12:47:37 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|