Add --force flag

This commit is contained in:
2026-02-24 19:03:41 -08:00
parent 23839f980e
commit 3c9285fddc
3 changed files with 88 additions and 43 deletions

View File

@ -700,7 +700,7 @@ return a list of many indices instead."
(clingon:make-option
:flag
:key :yes
:description "don't prompt, just ~A all matching things"
:description (format nil "don't prompt, just ~A all matching things" action)
:short-name #\y
:long-name "yes")))
@ -756,6 +756,7 @@ return a list of many indices instead."
(dry-run (clingon:getopt cmd :dry-run))
(quiet (clingon:getopt cmd :quiet))
(no-sort (and (clingon:getopt cmd :all) quiet))
(force (clingon:getopt cmd :force))
(objs (list-objects-for-command cmd no-sort))
(indices (get-indices-for-command "erase" cmd nil objs)))
(unless (eq indices :cancel)
@ -765,14 +766,16 @@ return a list of many indices instead."
do (mark-directorysizes-dirty (car (aref objs-arr i)))
do (dolist (info (cdr (aref objs-arr i)))
(cl-xdg-trash:empty-file info :dry-run dry-run
:update-directorysizes nil)))
:update-directorysizes nil
:force force)))
(loop with infos-arr = (coerce objs 'vector)
for i in indices
do (mark-directorysizes-dirty
(trashinfo-trash-directory (aref infos-arr i)))
do (cl-xdg-trash:empty-file (aref infos-arr i)
:dry-run dry-run
:update-directorysizes nil))))))
:update-directorysizes nil
:force force))))))
(defun empty/options ()
"Return options for the \"empty\" subcommand."
@ -787,7 +790,13 @@ return a list of many indices instead."
:key :dry-run
:description "print what would happen without actually deleting anything"
:short-name #\N
:long-name "dry-run"))))
:long-name "dry-run")
(clingon:make-option
:flag
:key :force
:description "attempt to change file permissions to allow deleting"
:short-name #\o
:long-name "force"))))
(defun empty/command ()
"Return the Clingon command for the \"empty\" subcommand."