diff --git a/editorconfig/cli.go b/editorconfig/cli.go index e308ee6..711e7cd 100644 --- a/editorconfig/cli.go +++ b/editorconfig/cli.go @@ -1,53 +1,9 @@ package editorconfig import ( - "fmt" "github.com/codegangsta/cli" - "strconv" - "strings" ) -func LsCommand(c *cli.Context) error { - files, err := FindSourceFiles(c.Args()) - if err != nil { - return err - } - nbFiles := strconv.Itoa(len(files)) - fmt.Println(nbFiles + " source files are matched by the paths you gave " + "(" + strings.Join(c.Args(), ", ") + ")") - for _, file := range files { - fmt.Println(file) - } - fmt.Println() - - configs := FindConfigFiles(files) - nbConfig := strconv.Itoa(len(configs)) - fmt.Println(nbConfig + " .editorconfig files were found that apply to your files") - for _, c := range configs { - if c.IsRoot() { - fmt.Println("A root .editorconfig is in " + c.Path) - } else { - fmt.Println("A non-root .editorconfig is in " + c.Path) - } - } - - fmt.Println() - - return nil -} - -func RulesCommand(c *cli.Context) error { - path := c.Args()[0] - configs := FindConfigFiles([]string{path}) - rules := GetRulesToApplyToSourcePath(path, configs) - - fmt.Printf("%d rules match the path %s\n", len(rules), path) - for key, value := range rules { - fmt.Println(key + " = " + value) - } - - return nil -} - func CreateCliApp() *cli.App { app := cli.NewApp() diff --git a/editorconfig/ls_command.go b/editorconfig/ls_command.go new file mode 100644 index 0000000..c53044e --- /dev/null +++ b/editorconfig/ls_command.go @@ -0,0 +1,36 @@ +package editorconfig + +import ( + "fmt" + "github.com/codegangsta/cli" + "strconv" + "strings" +) + +func LsCommand(c *cli.Context) error { + files, err := FindSourceFiles(c.Args()) + if err != nil { + return err + } + nbFiles := strconv.Itoa(len(files)) + fmt.Println(nbFiles + " source files are matched by the paths you gave " + "(" + strings.Join(c.Args(), ", ") + ")") + for _, file := range files { + fmt.Println(file) + } + fmt.Println() + + configs := FindConfigFiles(files) + nbConfig := strconv.Itoa(len(configs)) + fmt.Println(nbConfig + " .editorconfig files were found that apply to your files") + for _, c := range configs { + if c.IsRoot() { + fmt.Println("A root .editorconfig is in " + c.Path) + } else { + fmt.Println("A non-root .editorconfig is in " + c.Path) + } + } + + fmt.Println() + + return nil +} diff --git a/editorconfig/rules_command.go b/editorconfig/rules_command.go new file mode 100644 index 0000000..2b6cf92 --- /dev/null +++ b/editorconfig/rules_command.go @@ -0,0 +1,19 @@ +package editorconfig + +import ( + "fmt" + "github.com/codegangsta/cli" +) + +func RulesCommand(c *cli.Context) error { + path := c.Args()[0] + configs := FindConfigFiles([]string{path}) + rules := GetRulesToApplyToSourcePath(path, configs) + + fmt.Printf("%d rules match the path %s\n", len(rules), path) + for key, value := range rules { + fmt.Println(key + " = " + value) + } + + return nil +}