@@ -21,7 +21,6 @@ import (
2121
2222var cliTaskIdOverride string
2323var jsonOutput bool
24- var accessType = model .AccessTypeCli
2524
2625func Cmd () * cobra.Command {
2726 var c cobra.Command
@@ -36,7 +35,6 @@ func Cmd() *cobra.Command {
3635
3736func scanRun (cmd * cobra.Command , args []string ) {
3837 if jsonOutput {
39- accessType = model .AccessTypeIdea
4038 ideascanRun (cmd , args )
4139 return
4240 }
@@ -84,15 +82,15 @@ func scanRun(cmd *cobra.Command, args []string) {
8482 exitcode .Set (1 )
8583 return
8684 }
87- e = config .WriteRepoConfig (ctx , scanDir , accessType , config.RepoConfig {TaskId : cliTaskIdOverride })
85+ e = config .WriteRepoConfig (ctx , scanDir , model . AccessTypeCli , config.RepoConfig {TaskId : cliTaskIdOverride })
8886 if e != nil {
8987 cv .DisplayInitializeFailed (ctx , e )
9088 logger .Error (e )
9189 exitcode .Set (1 )
9290 return
9391 }
9492 }
95- _ , e = scan (ctx , scanDir , accessType )
93+ _ , e = scan (ctx , scanDir , model . AccessTypeCli )
9694 if e != nil {
9795 logger .Error (e )
9896 exitcode .Set (1 )
@@ -115,10 +113,14 @@ func IdeaScan() *cobra.Command {
115113func ideascanRun (cmd * cobra.Command , args []string ) {
116114 var (
117115 // workaround
118- ctx = ui .With (context .TODO (), ui.None {})
119- scanDir = args [0 ]
120- e error
116+ ctx = ui .With (context .TODO (), ui.None {})
117+ scanDir = args [0 ]
118+ e error
119+ accessType = model .AccessTypeIdea
121120 )
121+ if cmd .Use == "scan" {
122+ accessType = model .AccessTypeCli
123+ }
122124 // get absolute path and check if a directory
123125 scanDir , e = filepath .Abs (scanDir )
124126 if e != nil {
@@ -159,7 +161,7 @@ func ideascanRun(cmd *cobra.Command, args []string) {
159161 exitcode .Set (1 )
160162 return
161163 }
162- e = config .WriteRepoConfig (ctx , scanDir , model . AccessTypeIdea , config.RepoConfig {TaskId : cliTaskIdOverride })
164+ e = config .WriteRepoConfig (ctx , scanDir , accessType , config.RepoConfig {TaskId : cliTaskIdOverride })
163165 if e != nil {
164166 cv .DisplayInitializeFailed (ctx , e )
165167 logger .Error (e )
@@ -168,7 +170,7 @@ func ideascanRun(cmd *cobra.Command, args []string) {
168170 }
169171 }
170172
171- task , e := scan (ctx , scanDir , model . AccessTypeIdea )
173+ task , e := scan (ctx , scanDir , accessType )
172174 if e != nil {
173175 autoReportIde (e )
174176 logger .Error (e )
0 commit comments