@@ -32,11 +32,13 @@ var initCmd = &cobra.Command{
3232
3333 config .Config .CreateLocalCodacyDir ()
3434
35- if len (codacyRepositoryToken ) == 0 {
35+ cliLocalMode := len (codacyRepositoryToken ) == 0
36+
37+ if cliLocalMode {
3638 fmt .Println ()
3739 fmt .Println ("ℹ️ No project token was specified, skipping fetch configurations" )
3840 noTools := []tools.Tool {}
39- err := createConfigurationFile (noTools )
41+ err := createConfigurationFiles (noTools , cliLocalMode )
4042 if err != nil {
4143 log .Fatal (err )
4244 }
@@ -45,7 +47,7 @@ var initCmd = &cobra.Command{
4547 if err != nil {
4648 log .Fatal (err )
4749 }
48- err = createConfigurationFile (apiTools )
50+ err = createConfigurationFiles (apiTools , cliLocalMode )
4951 if err != nil {
5052 log .Fatal (err )
5153 }
@@ -64,7 +66,7 @@ var initCmd = &cobra.Command{
6466 },
6567}
6668
67- func createConfigurationFile (tools []tools.Tool ) error {
69+ func createConfigurationFiles (tools []tools.Tool , cliLocalMode bool ) error {
6870 configFile , err := os .Create (config .Config .ProjectConfigFile ())
6971 defer configFile .Close ()
7072 if err != nil {
@@ -76,6 +78,17 @@ func createConfigurationFile(tools []tools.Tool) error {
7678 log .Fatal (err )
7779 }
7880
81+ cliConfigFile , err := os .Create (config .Config .CliConfigFile ())
82+ defer cliConfigFile .Close ()
83+ if err != nil {
84+ log .Fatal (err )
85+ }
86+
87+ _ , err = cliConfigFile .WriteString (cliConfigFileTemplate (cliLocalMode ))
88+ if err != nil {
89+ log .Fatal (err )
90+ }
91+
7992 return nil
8093}
8194
@@ -113,9 +126,21 @@ tools:
113126` , eslintVersion , trivyVersion , pylintVersion , pmdVersion )
114127}
115128
129+ func cliConfigFileTemplate (cliLocalMode bool ) string {
130+ var cliModeString string
131+
132+ if cliLocalMode {
133+ cliModeString = "local"
134+ } else {
135+ cliModeString = "remote"
136+ }
137+
138+ return fmt .Sprintf (`mode: %s` , cliModeString )
139+ }
140+
116141func buildRepositoryConfigurationFiles (token string ) error {
117- fmt .Println ("Building project configuration files ..." )
118- fmt .Println ("Fetching project configuration from codacy ..." )
142+ fmt .Println ("Building repository configuration files ..." )
143+ fmt .Println ("Fetching repository configuration from codacy ..." )
119144
120145 // API call to fetch settings
121146 url := CodacyApiBase + "/2.0/project/analysis/configuration"
0 commit comments