Skip to content

Commit

Permalink
-i, -a and -d options
Browse files Browse the repository at this point in the history
  • Loading branch information
vygr committed Apr 22, 2024
1 parent 2b3d690 commit 9eb7917
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ cntl-J for convenience.
Slowly but surely adding the usage lines for all the `ffi` bindings. This is
particularly important now we have the jump to function, push/pop actions.

Added `-d`, `-i` and `-a` options to `files` command.

------

Fix `forward.lisp` defs regexp !
Expand Down
23 changes: 20 additions & 3 deletions cmd/files.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,39 @@

options:
-h --help: this help info.
-i --imm: immediate dependencies.
-a --all: recursive dependencies.
-d --dirs: directories.

Find all files that match the prefix and postfix.
Find all paths that match the prefix and postfix.

prefix default "."
postfix default ""

eg.
files ./apps/wallpaper/ .tga})
(("-d" "--dirs")
,(lambda (args arg) (setq opt_d :t) args))
(("-i" "--imm:")
,(lambda (args arg) (setq opt_i :t) args))
(("-a" "--all")
,(lambda (args arg) (setq opt_a :t) args))
))

(defun main ()
;initialize pipe details and command args, abort on error
(when (and
(defq stdio (create-stdio))
(defq args (options stdio usage)))
(defq opt_d :nil opt_i :nil opt_a :nil
args (options stdio usage)))
(defq postfix (if (< (length args) 2) "." (second args))
prefix (if (< (length args) 3) "" (third args)))
(if (ends-with "/" postfix) (setq postfix (most postfix)))
(each print (files-all postfix `(,prefix)))))
(defq files (files-all postfix `(,prefix)))
(when opt_i
(defq out (list))
(each (# (each (# (push out %0)) %0)) (map (const files-depends) files))
(setq files (unique (sort (const cmp) out))))
(if opt_a (setq files (files-all-depends files)))
(if opt_d (setq files (files-dirs files)))
(each print files)))
5 changes: 4 additions & 1 deletion docs/reference/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ Usage: files [options] [prefix] [postfix]
options:
-h --help: this help info.
-i --imm: immediate dependencies.
-a --all: recursive dependencies.
-d --dirs: directories.
Find all files that match the prefix and postfix.
Find all paths that match the prefix and postfix.
prefix default "."
postfix default ""
Expand Down

0 comments on commit 9eb7917

Please sign in to comment.