未验证 提交 e61ce24b 编写于 作者: P Phodal HUANG

fix: rename package

上级 cd5083db
......@@ -49,3 +49,4 @@ language/java
language/g4/*.tokens
language/g4/*.go
language/g4/*.interp
coca
\ No newline at end of file
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
. "../adapter/call"
. "../adapter/identifier"
)
var collCmd *cobra.Command = &cobra.Command{
Use: "analysis",
Short: "analysis package",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
importPath := cmd.Flag("path").Value.String()
if importPath != "" {
callApp := new(JavaCallApp)
callApp.AnalysisPath(importPath)
identifierApp := new(JavaIdentifierApp)
identifierApp.AnalysisPath(importPath)
}
},
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringP("path", "p", "Code Path", "example -p src/main")
viper.BindPFlag("path", rootCmd.PersistentFlags().Lookup("path"))
}
......@@ -14,34 +14,23 @@ var (
userLicense string
rootCmd = &cobra.Command{
Use: "phocli",
Use: "coca",
Short: "A generator for Cobra based Applications",
Long: `phocli`,
Long: `coca`,
}
)
// Execute executes the root command.
func Execute() error {
fmt.Println(rootCmd.Flag("author").Value.String())
fmt.Println(rootCmd.Flag("config").Value.String())
return rootCmd.Execute()
}
func init() {
rootCmd.AddCommand(collCmd)
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.cobra.yaml)")
rootCmd.PersistentFlags().StringP("author", "a", "YOUR NAME", "author name for copyright attribution")
rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
rootCmd.PersistentFlags().Bool("viper", true, "use Viper for configuration")
viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))
viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))
viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>")
viper.SetDefault("license", "apache")
//rootCmd.AddCommand(addCmd)
//rootCmd.AddCommand(initCmd)
}
func initConfig() {
......
package main
import (
"./cmd"
)
func main() {
cmd.Execute()
}
package main
import (
"os"
. "./adapter/call"
)
func main() {
//cmd.Execute()
path := "/Users/fdhuang/learn/coca/poc/src/main"
if len(os.Args) > 1 {
path = os.Args[1:][0]
}
callApp := new(JavaCallApp)
callApp.AnalysisPath(path)
//
//identifierApp := new(JavaIdentifierApp)
//identifierApp.AnalysisPath(path)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册