@@ -12,49 +12,48 @@ import (
1212
1313type cmdBlueprintsUpload struct {
1414 cmdBlueprints
15+ blueprintPath string
1516}
1617
1718func buildCmdBlueprintsUpload () * cli.Command {
1819 cmd := & cmdBlueprintsUpload {}
1920 return & cli.Command {
2021 Name : "upload" ,
21- Usage : "Upload blueprint directory into Platform" ,
22+ Usage : "Upload blueprint into Platform" ,
2223 CustomHelpTemplate : cmd .HelpTemplate (),
2324 Flags : cmd .Flags (),
2425 Before : cmd .Before ,
25- Args : true ,
26- ArgsUsage : "<blueprint path (zip file or directory)>" ,
2726 Action : func (cliCtx * cli.Context ) error {
28- return cmd .upload (cliCtx .Context , cliCtx . Args (). Get ( 0 ) )
27+ return cmd .upload (cliCtx .Context )
2928 },
3029 }
3130}
3231
33- func (c * cmdBlueprintsUpload ) Before ( cliCtx * cli.Context ) error {
34- if err := c .cmdBlueprints .Before ( cliCtx ); err != nil {
35- return err
36- }
37-
38- if cliCtx . Args (). Get ( 0 ) == "" {
39- return errBlueprintPathMissed
40- }
41- return nil
32+ func (c * cmdBlueprintsUpload ) Flags () [] cli.Flag {
33+ flags := c .cmdBlueprints .Flags ()
34+ return append ( flags , & cli. StringFlag {
35+ Name : "path" ,
36+ Aliases : [] string { "p" },
37+ Usage : "blueprint path (zip file or directory)" ,
38+ Destination : & c . blueprintPath ,
39+ Required : true ,
40+ })
4241}
4342
44- func (c * cmdBlueprintsUpload ) upload (ctx context.Context , blueprintPath string ) error {
45- fi , err := os .Stat (blueprintPath )
43+ func (c * cmdBlueprintsUpload ) upload (ctx context.Context ) error {
44+ fi , err := os .Stat (c . blueprintPath )
4645 if err != nil {
4746 return fmt .Errorf ("check blueprint path: %w" , err )
4847 }
4948
5049 var data []byte
5150 if fi .IsDir () {
52- data , err = zipDir (blueprintPath )
51+ data , err = zipDir (c . blueprintPath )
5352 if err != nil {
5453 return fmt .Errorf ("zip blueprint directory: %w" , err )
5554 }
5655 } else {
57- data , err = os .ReadFile (blueprintPath )
56+ data , err = os .ReadFile (c . blueprintPath )
5857 if err != nil {
5958 return fmt .Errorf ("read blueprint zip file: %w" , err )
6059 }
0 commit comments