[fix] fix bugs on gen-ide-env cmd.
This commit is contained in:
parent
2b21e934e7
commit
38866b832d
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"sylixos-uploader/detector"
|
"sylixos-uploader/detector"
|
||||||
|
|
||||||
|
@ -41,14 +42,15 @@ Generate environment variables from IDE projects.`,
|
||||||
s := detector.NewSylixOSPrj(path)
|
s := detector.NewSylixOSPrj(path)
|
||||||
if s.IsSylixOSPrj() {
|
if s.IsSylixOSPrj() {
|
||||||
// 输出结果
|
// 输出结果
|
||||||
fmt.Printf("export WORKSPACE_%s=%s\n", envVarName, path)
|
absPath, err := filepath.Abs(relativePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Printf("export WORKSPACE_%s=%s\n", envVarName, absPath)
|
||||||
if strings.Contains(relativePath, "-") {
|
if strings.Contains(relativePath, "-") {
|
||||||
fmt.Printf("echo \"you have to change \\$(WORKSPACE_%s) to \\$(WORKSPACE_%s) in all config.mk\"\n", envVarNameOrgin, envVarName)
|
fmt.Printf("echo \"you have to change \\$(WORKSPACE_%s) to \\$(WORKSPACE_%s) in all config.mk\"\n", envVarNameOrgin, envVarName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 阻止深入子目录
|
|
||||||
return filepath.SkipDir
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
@ -59,9 +61,26 @@ Generate environment variables from IDE projects.`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var fakeGenIdeEnvCmd = &cobra.Command{
|
||||||
RootCmd.AddCommand(genIdeEnvCmd)
|
Use: "gen-ide-env",
|
||||||
|
Short: "usage: source <(sylixos-uploader gen-ide-env --workspace <path>)",
|
||||||
// Adding flags with long names
|
Long: `usage: source <(sylixos-uploader gen-ide-env --workspace <path>)`,
|
||||||
genIdeEnvCmd.Flags().StringVar(&WorkSpacePath, "workspace", "", "Workspace path")
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
fmt.Printf("This command is not supported on %s platform.\n", runtime.GOOS)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "linux", "darwin":
|
||||||
|
RootCmd.AddCommand(genIdeEnvCmd)
|
||||||
|
|
||||||
|
// Adding flags with long names
|
||||||
|
genIdeEnvCmd.Flags().StringVar(&WorkSpacePath, "workspace", "", "Workspace path")
|
||||||
|
default:
|
||||||
|
RootCmd.AddCommand(fakeGenIdeEnvCmd)
|
||||||
|
|
||||||
|
// Adding flags with long names
|
||||||
|
fakeGenIdeEnvCmd.Flags().StringVar(&WorkSpacePath, "workspace", "", "Workspace path")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user