cmd/ctrld: fix mis-handling of start alias

For "ctrld start", os.Args length is just 2, so we we could not shorten
it from 3.
This commit is contained in:
Cuong Manh Le
2023-01-05 18:19:05 +07:00
committed by Cuong Manh Le
parent 114ef9aad6
commit 7b13fd862d

View File

@@ -151,7 +151,11 @@ func initCLI() {
Run: func(cmd *cobra.Command, args []string) {
cfg := &service.Config{}
*cfg = *svcConfig
cfg.Arguments = append([]string{"run"}, os.Args[3:]...)
osArgs := os.Args[2:]
if os.Args[1] == "service" {
osArgs = os.Args[3:]
}
cfg.Arguments = append([]string{"run"}, osArgs...)
if dir, err := os.UserHomeDir(); err == nil {
// WorkingDirectory is not supported on Windows.
cfg.WorkingDirectory = dir