(out interface{ Write(p []byte) (int, error) }, app string, scope string, args []string)
| 130 | } |
| 131 | |
| 132 | func showEditorConfig(out interface{ Write(p []byte) (int, error) }, app string, scope string, args []string) error { |
| 133 | tool, ok := editorconfig.DefaultRegistry().Get(app) |
| 134 | if !ok { |
| 135 | return fmt.Errorf("Unknown app: %s", app) |
| 136 | } |
| 137 | configs := tool.LoadAll() |
| 138 | scopes := []string{"user", "project"} |
| 139 | if scope != "" { |
| 140 | scopes = []string{scope} |
| 141 | } |
| 142 | merged := map[string]string{} |
| 143 | for _, s := range scopes { |
| 144 | scoped, ok := configs[s] |
| 145 | if !ok { |
| 146 | continue |
| 147 | } |
| 148 | for k, v := range editorconfig.Flatten(scoped.Data, app) { |
| 149 | merged[k] = v |
| 150 | } |
| 151 | } |
| 152 | if len(merged) == 0 { |
| 153 | fmt.Fprintf(out, "No configuration found for %s\n", app) |
| 154 | return nil |
| 155 | } |
| 156 | keys := make([]string, 0, len(merged)) |
| 157 | for k := range merged { |
| 158 | keys = append(keys, k) |
| 159 | } |
| 160 | sort.Strings(keys) |
| 161 | filter := "" |
| 162 | if len(args) == 1 { |
| 163 | filter = args[0] |
| 164 | } |
| 165 | for _, k := range keys { |
| 166 | if filter != "" && !strings.HasPrefix(k, filter) { |
| 167 | continue |
| 168 | } |
| 169 | fmt.Fprintf(out, "%s = %s\n", k, merged[k]) |
| 170 | } |
| 171 | return nil |
| 172 | } |
| 173 | |
| 174 | func (a *App) configSetCommand(state *globalState) *cobra.Command { |
| 175 | var app string |
no test coverage detected