@@ -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
6971 configFile , err := os .Create (config .Config .ProjectConfigFile ())
7072 defer configFile .Close ()
@@ -77,6 +79,17 @@ func createConfigurationFile(tools []tools.Tool) error {
7779 log .Fatal (err )
7880 }
7981
82+ cliConfigFile , err := os .Create (config .Config .CliConfigFile ())
83+ defer cliConfigFile .Close ()
84+ if err != nil {
85+ log .Fatal (err )
86+ }
87+
88+ _ , err = cliConfigFile .WriteString (cliConfigFileTemplate (cliLocalMode ))
89+ if err != nil {
90+ log .Fatal (err )
91+ }
92+
8093 return nil
8194}
8295
@@ -110,10 +123,22 @@ tools:
110123` , eslintVersion , trivyVersion , pylintVersion , pmdVersion )
111124}
112125
126+ func cliConfigFileTemplate (cliLocalMode bool ) string {
127+ var cliModeString string
128+
129+ if cliLocalMode {
130+ cliModeString = "local"
131+ } else {
132+ cliModeString = "remote"
133+ }
134+
135+ return fmt .Sprintf (`mode: %s` , cliModeString )
136+ }
137+
113138func buildRepositoryConfigurationFiles (token string ) error {
114139
115- fmt .Println ("Building project configuration files ..." )
116- fmt .Println ("Fetching project configuration from codacy ..." )
140+ fmt .Println ("Building repository configuration files ..." )
141+ fmt .Println ("Fetching repository configuration from codacy ..." )
117142
118143 // API call to fetch settings
119144 url := CodacyApiBase + "/2.0/project/analysis/configuration"
0 commit comments