github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state/internal/cmdtree/artifacts.go (about) 1 package cmdtree 2 3 import ( 4 "github.com/ActiveState/cli/internal/captain" 5 "github.com/ActiveState/cli/internal/locale" 6 "github.com/ActiveState/cli/internal/primer" 7 "github.com/ActiveState/cli/internal/runners/artifacts" 8 "github.com/ActiveState/cli/pkg/project" 9 ) 10 11 func newArtifactsCommand(prime *primer.Values) *captain.Command { 12 runner := artifacts.New(prime) 13 params := &artifacts.Params{Namespace: &project.Namespaced{}} 14 15 cmd := captain.NewCommand( 16 "artifacts", 17 locale.Tl("artifacts_title", "Artifacts"), 18 locale.Tl("artifacts_description", "Inspect artifacts created for your project"), 19 prime, 20 []*captain.Flag{ 21 { 22 Name: "all", 23 Description: locale.Tl("artifacts_flags_all_description", "List all artifacts, including individual package artifacts"), 24 Value: ¶ms.All, 25 }, 26 { 27 Name: "namespace", 28 Description: locale.Tl("artifacts_flags_namespace_description", "The namespace of the project to inspect artifacts for"), 29 Value: params.Namespace, 30 }, 31 { 32 Name: "commit", 33 Description: locale.Tl("artifacts_flags_commit_description", "The commit ID to inspect artifacts for"), 34 Value: ¶ms.CommitID, 35 }, 36 { 37 Name: "target", 38 Description: locale.Tl("artifacts_flags_target_description", "The target to report artifacts for"), 39 Value: ¶ms.Target, 40 }, 41 { 42 Name: "full-id", 43 Description: "List artifacts with their full identifier", 44 Value: ¶ms.Full, 45 }, 46 }, 47 []*captain.Argument{}, 48 func(_ *captain.Command, _ []string) error { 49 return runner.Run(params) 50 }, 51 ) 52 cmd.SetGroup(ProjectUsageGroup) 53 cmd.SetSupportsStructuredOutput() 54 cmd.DeprioritizeInHelpListing() 55 cmd.SetAliases("builds") 56 return cmd 57 } 58 59 func newArtifactsDownloadCommand(prime *primer.Values) *captain.Command { 60 runner := artifacts.NewDownload(prime) 61 params := &artifacts.DownloadParams{Namespace: &project.Namespaced{}} 62 63 cmd := captain.NewCommand( 64 "dl", 65 locale.Tl("artifacts_download_title", "Download build artifacts"), 66 locale.Tl("artifacts_download_description", "Download build artifacts for a given build"), 67 prime, 68 []*captain.Flag{ 69 { 70 Name: "namespace", 71 Description: locale.Tl("artifacts_download_flags_namespace_description", "The namespace of the project to download artifacts from"), 72 Value: params.Namespace, 73 }, 74 { 75 Name: "commit", 76 Description: locale.Tl("artifacts_download_flags_commit_description", "The commit ID to download artifacts from"), 77 Value: ¶ms.CommitID, 78 }, 79 { 80 Name: "target", 81 Description: locale.Tl("artifacts_dl_flags_target_description", "The target to download artifacts from"), 82 Value: ¶ms.Target, 83 }, 84 }, 85 []*captain.Argument{ 86 { 87 Name: "ID", 88 Description: locale.Tl("artifacts_download_arg_id", "The ID of the artifact to download"), 89 Value: ¶ms.BuildID, 90 Required: true, 91 }, 92 { 93 Name: "path", 94 Description: locale.Tl("artifacts_download_arg_path", "The target path to download the artifact to"), 95 Value: ¶ms.OutputDir, 96 }, 97 }, 98 func(_ *captain.Command, _ []string) error { 99 return runner.Run(params) 100 }, 101 ) 102 cmd.SetSupportsStructuredOutput() 103 return cmd 104 }