Last active
April 6, 2018 08:13
-
-
Save yamasushi/4c4353a6e710758acec9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
; https://gist.github.com/yamasushi/4c4353a6e710758acec9 | |
(use gauche.parseopt) | |
(use file.util) | |
(use srfi-11) | |
(define (main args) (let-args (cdr args) | |
( (help "h|help") | |
(ext-mode "x|ext" ) | |
(str-rx "e=s") . rest-args ) | |
(let [ | |
(from (if (null? rest-args) | |
(home-directory) | |
($ expand-path $ car rest-args) ) ) | |
(rx (string->regexp str-rx)) | |
] | |
(format (standard-error-port) "~s files~%" | |
(directory-fold | |
from | |
(^ (entry result) | |
(let-values ( ((dir fname ext ) (decompose-path entry) ) ) | |
;(print fname) | |
(if (rx (if ext-mode (if ext ext "") fname) ) | |
(begin (print entry) (+ result 1) ) | |
result ) ) ) | |
0 ) ) ) | |
) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment