@@ -54,9 +54,8 @@ type ExtraFlag struct {
5454// Arguments .
5555type Arguments struct {
5656 generator.Config
57- extends []* ExtraFlag
58- queryVersion bool
59- dependencyChecker * versions.DependencyChecker
57+ extends []* ExtraFlag
58+ queryVersion bool
6059}
6160
6261const (
@@ -98,7 +97,6 @@ func (a *Arguments) buildFlags(version string) *flag.FlagSet {
9897 "Turn on verbose mode." )
9998 f .BoolVar (& a .GenerateInvoker , "invoker" , false ,
10099 "Generate invoker side codes when service name is specified." )
101- f .StringVar (& a .IDLType , "type" , "unknown" , "Specify the type of IDL: 'thrift' or 'protobuf'." )
102100 f .Var (& a .Includes , "I" , "Add an IDL search path for includes." )
103101 f .Var (& a .ThriftOptions , "thrift" , "Specify arguments for the thrift go compiler." )
104102 f .Var (& a .Hessian2Options , "hessian2" , "Specify arguments for the hessian2 codec." )
@@ -196,10 +194,20 @@ func (a *Arguments) ParseArgs(version, curpath string, kitexArgs []string) (err
196194 a .ThriftOptions = append (a .ThriftOptions , "streamx" )
197195 }
198196 if a .Record {
199- a .RecordCmd = os . Args
197+ a .RecordCmd = append ([] string { "kitex" }, kitexArgs ... )
200198 }
201199 log .Verbose = a .Verbose
202200
201+ for i , inc := range a .Includes {
202+ if util .IsGitURL (inc ) {
203+ localGitPath , gitErr := util .RunGitCommand (inc )
204+ if gitErr != nil {
205+ return fmt .Errorf ("failed to pull IDL from git: %s, errMsg: %s\n You can execute 'rm -rf ~/.kitex' to clean the git cache and try again" , inc , gitErr .Error ())
206+ }
207+ a .Includes [i ] = localGitPath
208+ }
209+ }
210+
203211 // format -thrift xxx,xxx to -thrift xx -thrift xx
204212 thriftOptions := make ([]string , len (a .ThriftOptions ))
205213 for i := range a .ThriftOptions {
@@ -255,16 +263,11 @@ func (a *Arguments) checkIDL(files []string) error {
255263 }
256264 a .IDL = files [0 ]
257265
258- switch a .IDLType {
259- case Thrift , Protobuf :
260- case Unknown :
261- if typ , ok := guessIDLType (a .IDL ); ok {
262- a .IDLType = typ
263- } else {
264- return fmt .Errorf ("can not guess an IDL type from %q (unknown suffix), please specify with the '-type' flag" , a .IDL )
265- }
266- default :
267- return fmt .Errorf ("unsupported IDL type: %s" , a .IDLType )
266+ if typ , ok := guessIDLType (a .IDL ); ok {
267+ a .IDLType = typ
268+ } else {
269+ return fmt .Errorf ("the last parameter shoule be IDL filename (xxx.thrift or xxx.proto), for example: " +
270+ "\" kitex -service demo idl.thrift\" " )
268271 }
269272 return nil
270273}
@@ -369,19 +372,6 @@ func (a *Arguments) BuildCmd(out io.Writer) (*exec.Cmd, error) {
369372 return nil , fmt .Errorf ("failed to detect current executable: %s" , err .Error ())
370373 }
371374
372- for i , inc := range a .Includes {
373- if strings .HasPrefix (inc , "git@" ) || strings .HasPrefix (inc , "http://" ) || strings .HasPrefix (inc , "https://" ) {
374- localGitPath , errMsg , gitErr := util .RunGitCommand (inc )
375- if gitErr != nil {
376- if errMsg == "" {
377- errMsg = gitErr .Error ()
378- }
379- return nil , fmt .Errorf ("failed to pull IDL from git:%s\n You can execute 'rm -rf ~/.kitex' to clean the git cache and try again" , errMsg )
380- }
381- a .Includes [i ] = localGitPath
382- }
383- }
384-
385375 configkv := a .Config .Pack ()
386376 kas := strings .Join (configkv , "," )
387377 cmd := & exec.Cmd {
0 commit comments