forked from sindresorhus/trash-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·36 lines (31 loc) · 732 Bytes
/
cli.js
File metadata and controls
executable file
·36 lines (31 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
'use strict';
const updateNotifier = require('update-notifier');
const meow = require('meow');
const trash = require('trash');
const cli = meow(`
Usage
$ trash [flag] <path|glob> [...]
Examples
$ trash unicorn.png rainbow.png
$ trash '*.png' '!unicorn.png'
$ trash -v unicorn.png rainbow.png
`, {
string: ['_'],
// ignore all flags of `rm` program
boolean: ['r', 'f', 'i', 'd', 'P', 'R', 'v', 'W']
});
updateNotifier({pkg: cli.pkg}).notify();
if (cli.input.length === 0) {
console.error('Specify at least one path');
process.exit(1);
}
if (cli.flags.v) {
cli.input.forEach(entry => {
trash(entry).then(() => {
console.log(`Removed ${entry}`);
});
});
} else {
trash(cli.input);
}