-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.go
39 lines (36 loc) · 922 Bytes
/
convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package cmd
import (
"fmt"
"github.com/at0x0ft/pathru/pkg/domain"
"github.com/spf13/cobra"
"strings"
)
func NewConvertCommand(opts *rootOptions) *cobra.Command {
return &cobra.Command{
Use: "convert",
Short: "Only printing converted exec arguments",
Long: `Usage: pathru [options] convert <runtime service name> <execute command> -- [command arguments & options]`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return fmt.Errorf(
"arguments must be given more than 1 [actual = \"%v\"]",
args,
)
}
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
prjOpts, baseService := opts.getProjectOptions(), opts.getBaseService()
convertedArgs, err := domain.Convert(
prjOpts,
baseService,
args,
)
if err != nil {
return err
}
fmt.Printf("%v\n", strings.Join(convertedArgs, " "))
return nil
},
}
}