From 49f7969363b2819399931ef6e8655b5c9330d117 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 5 Jun 2023 18:09:24 +0200 Subject: [PATCH] set template in annotation --- cmd/workspace/workspace/import_dir.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cmd/workspace/workspace/import_dir.go b/cmd/workspace/workspace/import_dir.go index 33febe2bd..266a6a524 100644 --- a/cmd/workspace/workspace/import_dir.go +++ b/cmd/workspace/workspace/import_dir.go @@ -20,9 +20,16 @@ var importDirCmd = &cobra.Command{ .scala, .py, .sql, .r, .R, .ipynb are stripped of their extensions. `, - Annotations: map[string]string{}, - PreRunE: root.MustWorkspaceClient, - Args: cobra.ExactArgs(2), + Annotations: map[string]string{ + "template": cmdio.Heredoc(` + {{if eq .Type "IMPORT_STARTED"}}Import started + {{else if eq .Type "UPLOAD_COMPLETE"}}Uploaded {{.SourcePath}} -> {{.TargetPath}} + {{else if eq .Type "IMPORT_COMPLETE"}}Import completed + {{end}} + `), + }, + PreRunE: root.MustWorkspaceClient, + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { ctx := cmd.Context() sourcePath := args[0] @@ -75,12 +82,6 @@ var importDirCmd = &cobra.Command{ var importDirOverwrite bool func init() { - importDirCmd.Annotations["template"] = cmdio.Heredoc(` - {{if eq .Type "IMPORT_STARTED"}}Import started - {{else if eq .Type "UPLOAD_COMPLETE"}}Uploaded {{.SourcePath}} -> {{.TargetPath}} - {{else if eq .Type "IMPORT_COMPLETE"}}Import completed - {{end}} - `) importDirCmd.Flags().BoolVar(&importDirOverwrite, "overwrite", false, "Overwrite if file already exists in the workspace") Cmd.AddCommand(importDirCmd) }