Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion statik.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var (
flagNamespace = flag.String("ns", "default", "")
flagPkgCmt = flag.String("c", "", "")
flagInclude = flag.String("include", "*.*", "")
flagAllFiles = flag.Bool("a", false, "")

@jcchavezs jcchavezs May 4, 2020

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change it into flagIgnoreDotFiles to be more inline with its real purpose.

@yskopets yskopets May 4, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the name flagIgnoreDotFiles has a meaning opposite to -a ("do not ignore entries starting with .")

When a user runs statik -a or statik -a=true, they want to include dot files.
So, flagIgnoreDotFiles should be equal to ! flag.Bool("a"), which is very uncommon.

I don't mind renaming flagAllFiles. May be flagDoNotIgnoreDotFiles is less controversial ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe considerDotFiles is easier to grok?

)

const helpText = `statik [options]
Expand All @@ -59,6 +60,7 @@ Options:

-ns The namespace where assets will exist, "default" by default.
-f Override destination if it already exists, false by default.
-a Include hidden files, false by default.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the -a (like in ls) tho I'd prefer to use [their description])(https://linux.die.net/man/1/ls):

-a, --all
    do not ignore entries starting with . 

What do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sounds great. I will update it.

-include Wildcard to filter files to include, "*.*" by default.
-m Ignore modification times for deterministic output, false by default.
-Z Do not use compression, false by default.
Expand Down Expand Up @@ -207,7 +209,7 @@ func generateSource(srcPath string, includes string) (file *os.File, err error)
// No entry is needed for directories in a zip file.
// Each file is represented with a path, no directory
// entities are required to build the hierarchy.
if fi.IsDir() || strings.HasPrefix(fi.Name(), ".") {
if fi.IsDir() || (!*flagAllFiles && strings.HasPrefix(fi.Name(), ".")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think (!*flagIgnoreDotFiles && strings.HasPrefix(fi.Name(), ".")) is more readable, it could also be in a next if (it is OK to keep it in this if too).

return nil
}
relPath, err := filepath.Rel(srcPath, path)
Expand Down