Skip to content
Permalink
Browse files

Added a flag for ignoring a file/directory.

  • Loading branch information...
artob committed Jun 21, 2019
1 parent 682657e commit d0afb4dedae041de5c067041bce6e54ff7bd0481
Showing with 7 additions and 2 deletions.
  1. +5 −2 drycop/cmd/check.go
  2. +2 −0 drycop/cmd/root.go
@@ -66,11 +66,14 @@ func checkAgainstTemplate(project util.Project) bool {
}
expectedPath := osPathname[len(templatePath)+1:]
if dirent.IsDir() {
if dirent.Name() == ".git" {
return filepath.SkipDir
if dirent.Name() == ".git" || expectedPath == ignoredPath {
return filepath.SkipDir // skip the whole subdirectory
}
ok = project.CheckDirExists(expectedPath) && ok
} else {
if expectedPath == ignoredPath {
return nil // skip the file
}
ok = project.CheckFileExists(expectedPath) && ok
}
//fmt.Printf("%s %s\n", dirent.ModeType(), expectedPath) // DEBUG
@@ -19,6 +19,7 @@ var builderOverride enum.Builder
var languageOverride enum.Language
var frameworkOverride enum.Framework
var markupOverride string
var ignoredPath string
var debug bool
var verbose bool

@@ -47,6 +48,7 @@ func init() {
RootCmd.PersistentFlags().VarP(&languageOverride, "language", "L", "Set project language")
RootCmd.PersistentFlags().VarP(&frameworkOverride, "framework", "F", "Set project framework")
RootCmd.PersistentFlags().StringVarP(&markupOverride, "markup", "M", "", "Set project markup format")
RootCmd.PersistentFlags().StringVarP(&ignoredPath, "ignore", "I", "", "Skip a file or directory")
RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Be verbose")
RootCmd.SetVersionTemplate(`DRYcop {{printf "%s" .Version}}
`)

0 comments on commit d0afb4d

Please sign in to comment.
You can’t perform that action at this time.