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

Feature/skip #19

Merged
merged 8 commits into from Mar 6, 2020
Merged

Feature/skip #19

merged 8 commits into from Mar 6, 2020

Conversation

otiai10
Copy link
Owner

@otiai10 otiai10 commented Mar 6, 2020

Close #18

@otiai10
Copy link
Owner Author

otiai10 commented Mar 6, 2020

@julplee This is my idea for your usecase. Let me know your thought.

Copy link
Contributor

@julplee julplee left a comment

Choose a reason for hiding this comment

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

Yes that seems cleaner than my version!
If I want to send several files or directories to skip I have just to send several "skip" options to the options? Or should I send an array of strings to the skip option?

@otiai10
Copy link
Owner Author

otiai10 commented Mar 6, 2020

Now it's a function, you can define your own condition to check if it should be skipped or not.

This is just an example by using map.

opt := Options{
  Skip: func(src string) bool {
    return map[string]bool{
      "foo.txt": true, // ← skip
      "baa.txt": false, // NOT skipped
      "baz.txt": true, // ← skip
      // anything NOT specified will NOT be skipped
    }[src]
  },
}

Copy("dir_a", "dir_b", opt)

The test cases I wrote uses strings.HasSuffix.

@julplee
Copy link
Contributor

julplee commented Mar 6, 2020

OK perfect 👌

@otiai10 otiai10 merged commit b5d0589 into master Mar 6, 2020
@otiai10 otiai10 deleted the feature/skip branch March 6, 2020 14:22
@otiai10
Copy link
Owner Author

otiai10 commented Mar 6, 2020

Thanks @julplee. v1.1.0 is out now https://github.com/otiai10/copy/releases/tag/v1.1.0

@julplee
Copy link
Contributor

julplee commented Mar 6, 2020

Thank you very much!

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

2 participants