github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/cmd/state/internal/cmdtree/publish.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/publish"
     8  )
     9  
    10  func newPublish(prime *primer.Values) *captain.Command {
    11  	runner := publish.New(prime)
    12  	params := publish.Params{}
    13  	c := captain.NewCommand(
    14  		"publish",
    15  		locale.Tl("add_title", "Publish Ingredient"),
    16  		locale.Tl("add_description", "Publish an Ingredient for private consumption."),
    17  		prime,
    18  		[]*captain.Flag{
    19  			{
    20  				Name:        "edit",
    21  				Description: locale.Tl("author_upload_edit_description", "Create a revision for an existing ingredient, matched by their name and namespace."),
    22  				Value:       &params.Edit,
    23  			},
    24  			{
    25  				Name:        "editor",
    26  				Description: locale.Tl("author_upload_editor_description", "Edit the ingredient information in your editor before uploading."),
    27  				Value:       &params.Editor,
    28  			},
    29  			{
    30  				Name: "name",
    31  				Description: locale.Tl(
    32  					"author_upload_name_description",
    33  					"The name of the ingredient. Defaults to basename of filepath.",
    34  				),
    35  				Value: &params.Name,
    36  			},
    37  			{
    38  				Name: "version",
    39  				Description: locale.Tl(
    40  					"author_upload_version_description",
    41  					"Version of the ingredient (preferably semver).",
    42  				),
    43  				Value: &params.Version,
    44  			},
    45  			{
    46  				Name: "namespace",
    47  				Description: locale.Tl(
    48  					"author_upload_namespace_description",
    49  					"The namespace of the ingredient. Must start with 'private/<orgname>'.",
    50  				),
    51  				Value: &params.Namespace,
    52  			},
    53  			{
    54  				Name: "description",
    55  				Description: locale.Tl(
    56  					"author_upload_description_description",
    57  					"A short description summarizing what this ingredient is for.",
    58  				),
    59  				Value: &params.Description,
    60  			},
    61  			{
    62  				Name: "author",
    63  				Description: locale.Tl(
    64  					"author_upload_author_description",
    65  					"Ingredient author, in the format of \"[<name>] <email>\". Can be set multiple times.",
    66  				),
    67  				Value: &params.Authors,
    68  			},
    69  			{
    70  				Name: "depend",
    71  				Description: locale.Tl(
    72  					"author_upload_depend_description",
    73  					"Ingredient that this ingredient depends on, format as <namespace>/<name>[@<version>]. Can be set multiple times.",
    74  				),
    75  				Value: &params.Depends,
    76  			},
    77  			{
    78  				Name: "depend-runtime",
    79  				Description: locale.Tl(
    80  					"author_upload_dependruntime_description",
    81  					"Ingredient that this ingredient depends on during runtime, format as <namespace>/<name>[@<version>]. Can be set multiple times.",
    82  				),
    83  				Value: &params.DependsRuntime,
    84  			},
    85  			{
    86  				Name: "depend-build",
    87  				Description: locale.Tl(
    88  					"author_upload_dependbuild_description",
    89  					"Ingredient that this ingredient depends on during build, format as <namespace>/<name>[@<version>]. Can be set multiple times.",
    90  				),
    91  				Value: &params.DependsBuild,
    92  			},
    93  			{
    94  				Name: "depend-test",
    95  				Description: locale.Tl(
    96  					"author_upload_dependtest_description",
    97  					"Ingredient that this ingredient depends on during tests, format as <namespace>/<name>[@<version>]. Can be set multiple times.",
    98  				),
    99  				Value: &params.DependsTest,
   100  			},
   101  			{
   102  				Name: "feature",
   103  				Description: locale.Tl(
   104  					"author_upload_feature_description",
   105  					"Feature that this ingredient provides, format as <namespace>/<name>[@<version>]. Can be set multiple times.",
   106  				),
   107  				Value: &params.Features,
   108  			},
   109  			{
   110  				Name:        "meta",
   111  				Description: locale.Tl("author_upload_metafile_description", "A yaml file expressing the ingredient meta information. Use --editor to review the file format."),
   112  				Value:       &params.MetaFilepath,
   113  			},
   114  		},
   115  		[]*captain.Argument{
   116  			{
   117  				Name:        locale.Tl("filepath", "filepath"),
   118  				Description: locale.Tl("author_upload_filepath_description", "A tar.gz or zip archive containing the source files of the ingredient."),
   119  				Value:       &params.Filepath,
   120  			},
   121  		},
   122  		func(_ *captain.Command, _ []string) error {
   123  			return runner.Run(&params)
   124  		})
   125  	c.SetGroup(AuthorGroup)
   126  	return c
   127  }