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

simplify API for --parents option #21

Closed
guillaumevincent opened this issue Dec 13, 2015 · 10 comments
Closed

simplify API for --parents option #21

guillaumevincent opened this issue Dec 13, 2015 · 10 comments

Comments

@guillaumevincent
Copy link
Contributor

Hi,

If I want to copy all the html in assets directory and keep the directory structure inside dist directory I have to do the following command :

cpy '**/*.html' '../dist/' --cwd=assets --parents

I think the following command would be easier :

cpy 'assets/**/*.html' dist --parents
assets
├── index.html
├── robots.txt
└── test
    └── test.html

should return

dist
├── index.html
└── test
    └── test.html

not

dist
└── assets
    ├── index.html
    └── test
        └── test.html
npm -v
2.14.7

node -v
4.2.3

uname -a
Linux guillaume-x240 3.19.0-39-generic #44~14.04.1-Ubuntu SMP Wed Dec 2 10:00:35 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

here the red test guillaumevincent@fad2b31

@schnittstabil
Copy link
Collaborator

Saving some characters would be nice, but how cumbersome would be the cpy command to create current result?

dist
└── assets
    ├── index.html
    └── test
        └── test.html

@guillaumevincent
Copy link
Contributor Author

@schnittstabil :

cpy 'assets/**/*.html' 'dist/assets' --parents

@schnittstabil
Copy link
Collaborator

@guillaumevincent What about this:

cpy 'asset*/**/*.html' dist --parents

Should this copy

  1. assets/test/test.html to dist/assets/test/test.html, or
  2. assets/test/test.html to assets/test/test.html

@guillaumevincent
Copy link
Contributor Author

@schnittstabil I don't really know

My proposition was just to simplify the API.
I found difficult to found a simple way to copy all the html inside a folder to another folder.

I understand that cpy follow the API of linux cp method.
Maybe we can update the doc with an example.

@schnittstabil
Copy link
Collaborator

@guillaumevincent Propositions are always welcome.

I understand that cpy follow the API of linux cp method.

We don't have to, however most users expect a similar behavior.

@guillaumevincent Would you find a --cut-dirs option useful?

# instead of (1)
cpy --cwd=assets/test '**/*.html' '../../dist' --parents
# or
cd assets/test && cpy '**/*.html' '../../dist' --parents && cd ../..

# cut the first 2 directories (assets/test)
cpy 'assets/**/*.html' 'dist' --parents --cut-dirs=2  

# result:
dist
└── test.html

I'm not sure if we need this, personally I think the (1) command is sufficient.

@guillaumevincent
Copy link
Contributor Author

@schnittstabil you're right, the first command is sufficient.

Maybe something in the doc :

$ cpy --help

  Usage
    $ cpy <source>... <destination> [--no-overwrite] [--parents] [--cwd=<dir>] [--rename=<filename>]

  Options
    --no-overwrite       Don't overwrite the destination
    --parents            Preseve path structure
    --cwd=<dir>          Working directory for source files
    --rename=<filename>  Rename all <source> filenames to <filename>

  <source> can contain globs if quoted

  Examples:
  Copy all png in src directory into dist except src/goat.png

    $ cpy 'src/*.png' '!src/goat.png' dist

  Copy all html inside src directory into dist and keep path structure

    $ cpy '**/*.html' '../dist/' --cwd=src --parents



@schnittstabil
Copy link
Collaborator

Why not, a --cwd-example wouldn't harm. @sindresorhus What do you think?

@sindresorhus
Copy link
Owner

👍

@schnittstabil
Copy link
Collaborator

@guillaumevincent Would you like to create a pull request?

@guillaumevincent
Copy link
Contributor Author

@schnittstabil pull request #22
tell me if it's not what you think

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

No branches or pull requests

3 participants