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(cli): Added --confirm (-c) flag for CLI usage #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Options:
* `-f <regex>`, `--filter <regex>`: Filter out any items that match `<regex>`, a case-insensitive regex pattern.
* `-h`, `--help`: Display this usage info.
* `-o`, `--overwrite`: Overwrite the destination exists if it exists.
* `-c`, `--confirm`: After the copy operation, stat all the files and report errors if any are missing.
* `-v`, `--version`: Display the cpr version.

Note that the CLI's `filter` option is simpler than the original NodeJS API, only accepting case-insensitive regular expression patterns and not functions.
Expand Down
5 changes: 3 additions & 2 deletions bin/cpr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var fs = require('fs');
var minimist = require('minimist');

var argv = minimist(process.argv.slice(2), {
alias: { d:'delete-first', f:'filter', h:'help', o:'overwrite', v:'version' }
alias: { d:'delete-first', f:'filter', h:'help', o:'overwrite', c:'confirm', v:'version' }
});

if (argv.v) {
Expand All @@ -27,7 +27,8 @@ if (argv.f) {
cpr(argv._[0], argv._[1], {
deleteFirst: argv.d,
filter: filter,
overwrite: argv.o
overwrite: argv.o,
confirm: argv.c
}, function (err) {
if (err) {
console.error('Error: ' + err.message);
Expand Down