Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: add -a option to allow inclusion of hidden files #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yskopets
Copy link

@yskopets yskopets commented May 1, 2020

No description provided.

@@ -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
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
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.

@@ -49,6 +49,7 @@ var (
flagNamespace = flag.String("ns", "default", "")
flagPkgCmt = flag.String("c", "", "")
flagInclude = flag.String("include", "*.*", "")
flagAllFiles = flag.Bool("a", false, "")
Copy link
Collaborator

@jcchavezs jcchavezs May 4, 2020

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.

Copy link
Author

@yskopets yskopets May 4, 2020

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
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?

@@ -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
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).

@DemonLms
Copy link

DemonLms commented Jun 3, 2020

Can we use include to implement this function instead of adding a new switch.
I submitted a new PR [#114 ], think about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants