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

Want option to confim removal of files for mrm #335

Closed
jordanhendricks opened this issue Nov 20, 2017 · 1 comment
Closed

Want option to confim removal of files for mrm #335

jordanhendricks opened this issue Nov 20, 2017 · 1 comment
Assignees

Comments

@jordanhendricks
Copy link
Contributor

Having accidentally removed some files in Manta (via improper editing of previous commands), I think it would be nice for the to optionally check that the file you are trying to remove from Manta is correct.

That is, I want something analogous to the behavior of rm -i:

$ ls
not-important.txt  very-important.txt

$ rm -i very-important.txt 
 remove very-important.txt? n

$ rm -i not-important.txt 
remove not-important.txt? y

$ ls
very-important.txt

The -i option for mrm is already claimed, so the confirmation option for mrm would need to be a different flag from rm.

@bahamas10
Copy link
Contributor

bahamas10 commented Aug 17, 2018

https://cr.joyent.us/#/c/4714/

mrmdir

$ ./bin/mmkdir ~~/stor/test-dir{1..5}
$ ./bin/mls
test-dir1/
test-dir2/
test-dir3/
test-dir4/
test-dir5/
$ ./bin/mrmdir -I ~~/stor/test-dir{1..5}
remove directory `/dave/stor/test-dir1` [y/N]?: n
remove directory `/dave/stor/test-dir2` [y/N]?: 
remove directory `/dave/stor/test-dir3` [y/N]?: foo
remove directory `/dave/stor/test-dir4` [y/N]?: y
remove directory `/dave/stor/test-dir5` [y/N]?: nope
$ ./bin/mls
test-dir1/
test-dir2/
test-dir3/
test-dir5/

mrm

$ touch empty
$ for f in ~~/stor/test-object{1..5}; do mput -f empty "$f"; done
$ mls
test-object1
test-object2
test-object3
test-object4
test-object5
$ ./bin/mrm -I ~~/stor/test-object{1..5}
remove object `/dave/stor/test-object1` [y/N]?: n
remove object `/dave/stor/test-object2` [y/N]?: 
remove object `/dave/stor/test-object3` [y/N]?: foo
remove object `/dave/stor/test-object4` [y/N]?: y
remove object `/dave/stor/test-object5` [y/N]?: nope
$ mls
test-object1
test-object2
test-object3
test-object5

Tests created for mrm and mrmdir

$ ./node_modules/.bin/nodeunit test/mrmdir.test.js 

mrmdir.test.js
✔ setup: create test tree at /dave/stor/node-manta-test-mrmdir-01d47615
✔ mrmdir (no arguments)
✔ mrmdir -I fails without tty
✔ mrmdir 1 directory
✔ remove remaining directories
✔ ensure test tree is empty
✔ cleanup: rm test tree /dave/stor/node-manta-test-mrmdir-01d47615

OK: 11 assertions (18414ms)
$ ./node_modules/.bin/nodeunit test/mrm.test.js 

mrm.test.js
✔ setup: create test tree at /dave/stor/node-manta-test-mrm-91cf20a6
✔ mrm (no arguments)
✔ mrm -I fails without tty
✔ mrm 1 directory
✔ remove remaining directories
✔ mrm 1 object
✔ remove remaining objects
✔ ensure test tree is empty
✔ cleanup: rm test tree /dave/stor/node-manta-test-mrm-91cf20a6

OK: 15 assertions (41372ms)

joyent-automation pushed a commit that referenced this issue Sep 24, 2018
Reviewed by: Kelly McLaughlin <kelly.mclaughlin@joyent.com>
Approved by: Jordan Hendricks <jordan.hendricks@joyent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants