github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state/internal/cmdtree/bundles.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/packages" 8 "github.com/ActiveState/cli/pkg/platform/model" 9 ) 10 11 func newBundlesCommand(prime *primer.Values) *captain.Command { 12 runner := packages.NewList(prime) 13 14 params := packages.ListRunParams{} 15 16 return captain.NewCommand( 17 "bundles", 18 locale.Tl("bundles_title", "Listing Bundles"), 19 locale.Tl("bundles_cmd_description", "Manage bundles used in your project"), 20 prime, 21 []*captain.Flag{ 22 { 23 Name: "commit", 24 Description: locale.Tl("bundle_list_flag_commit_description", "The commit that the listing should be based on"), 25 Value: ¶ms.Commit, 26 }, 27 { 28 Name: "bundle", 29 Description: locale.Tl("bundle_list_flag_name_description", "The filter for the bundles names to include in the listing"), 30 Value: ¶ms.Name, 31 }, 32 { 33 Name: "namespace", 34 Description: locale.Tl("namespace_list_flag_bundle_description", "The namespace bundles should be listed from"), 35 Value: ¶ms.Project, 36 }, 37 }, 38 []*captain.Argument{}, 39 func(_ *captain.Command, _ []string) error { 40 return runner.Run(params, model.NamespaceBundle) 41 }, 42 ).SetGroup(PackagesGroup).SetSupportsStructuredOutput().SetUnstable(true) 43 } 44 45 func newBundleInstallCommand(prime *primer.Values) *captain.Command { 46 runner := packages.NewInstall(prime) 47 48 params := packages.InstallRunParams{} 49 50 return captain.NewCommand( 51 "install", 52 locale.Tl("bundle_install_title", "Installing Bundle"), 53 locale.Tl("bundle_install_cmd_description", "Add a new bundle to your project"), 54 prime, 55 []*captain.Flag{}, 56 []*captain.Argument{ 57 { 58 Name: locale.T("bundle_arg_nameversion"), 59 Description: locale.T("bundle_arg_nameversion_description"), 60 Value: ¶ms.Packages, 61 Required: true, 62 }, 63 }, 64 func(_ *captain.Command, _ []string) error { 65 return runner.Run(params, model.NamespaceBundle) 66 }, 67 ).SetSupportsStructuredOutput() 68 } 69 70 func newBundleUninstallCommand(prime *primer.Values) *captain.Command { 71 runner := packages.NewUninstall(prime) 72 73 params := packages.UninstallRunParams{} 74 75 return captain.NewCommand( 76 "uninstall", 77 locale.Tl("bundle_uninstall_title", "Uninstalling Bundle"), 78 locale.Tl("bundle_uninstall_cmd_description", "Remove bundle from your project"), 79 prime, 80 []*captain.Flag{}, 81 []*captain.Argument{ 82 { 83 Name: locale.T("bundle_arg_name"), 84 Description: locale.T("bundle_arg_name_description"), 85 Value: ¶ms.Packages, 86 Required: true, 87 }, 88 }, 89 func(_ *captain.Command, _ []string) error { 90 return runner.Run(params, model.NamespaceBundle) 91 }, 92 ).SetSupportsStructuredOutput() 93 } 94 95 func newBundlesSearchCommand(prime *primer.Values) *captain.Command { 96 runner := packages.NewSearch(prime) 97 98 params := packages.SearchRunParams{} 99 100 return captain.NewCommand( 101 "search", 102 locale.Tl("bundle_search_title", "Searching Bundles"), 103 locale.Tl("bundle_search_cmd_description", "Search for all available bundles that can be added to your project"), 104 prime, 105 []*captain.Flag{ 106 { 107 Name: "language", 108 Description: locale.Tl("bundle_search_flag_language_description", "The language used to constrain search results"), 109 Value: ¶ms.Language, 110 }, 111 { 112 Name: "exact-term", 113 Description: locale.Tl("bundle_search_flag_exact-term_description", "Ensure that search results match search term exactly"), 114 Value: ¶ms.ExactTerm, 115 }, 116 }, 117 []*captain.Argument{ 118 { 119 Name: locale.T("bundle_arg_name"), 120 Description: locale.T("bundle_arg_name_description"), 121 Value: ¶ms.Ingredient, 122 Required: true, 123 }, 124 }, 125 func(_ *captain.Command, _ []string) error { 126 return runner.Run(params, model.NamespaceBundle) 127 }, 128 ).SetSupportsStructuredOutput() 129 }