site-neo/pfiles.rb

56 lines
1.1 KiB
Ruby
Raw Normal View History

2023-02-10 19:02:43 +00:00
#!/usr/bin/ruby
# pfiles.rb
2023-12-08 15:04:21 +00:00
# v1.1-p1
abort "\x1B[1;31mERR\x1B[0m: No arguments supplied" if ARGV.length == 0
2023-02-11 14:08:06 +00:00
require 'find'
2023-02-17 18:17:33 +00:00
ignore=!File.file?('dat/ignore.txt') ? [] : File.readlines('dat/ignore.txt')
2023-02-11 14:08:06 +00:00
if ignore != []
2023-10-27 13:56:04 +00:00
ignore.map! { |i| "in/#{i}" }
2023-02-11 14:08:06 +00:00
end
class Enumerator
2023-10-27 13:36:56 +00:00
def collect
out=Array.new
for i in self
out.push(i)
end
return out
end
2023-02-11 14:08:06 +00:00
end
2023-12-08 15:04:21 +00:00
l=Find.find('in').collect
2023-02-11 14:08:06 +00:00
case ARGV.first
when "doc"
2023-10-27 13:36:56 +00:00
for i in l do
2023-12-08 15:04:21 +00:00
next if ignore.include?(i) or /(?<!\.e)\.html$/.match?(i)
2023-12-07 17:30:19 +00:00
if /\.(txti|org|md|e.html)$/.match?(i)
2023-10-27 13:36:56 +00:00
print i
print ' ' unless i==l.last
end
end
2023-02-11 14:08:06 +00:00
when "sass"
2023-10-27 13:36:56 +00:00
for i in l do
next if ignore.include?(i)
if /\.s[ac]ss$/.match?(i)
print i
print ' ' unless i==l.last
end
end
2023-02-11 14:08:06 +00:00
when "dir"
2023-10-27 13:36:56 +00:00
for i in l do
2023-12-08 15:04:21 +00:00
next if ignore.include?(i) or i == ".git"
2023-10-27 13:36:56 +00:00
if File.directory?(i)
print i
print ' ' unless i==l.last
end
end
2023-02-11 14:08:06 +00:00
when "rest"
2023-10-27 13:36:56 +00:00
for i in l do
next if ignore.include?(i)
2023-10-27 13:56:04 +00:00
unless /\.(s[ac]ss|txti|org|md|html)$/.match?(i) or File.directory?(i)
2023-10-27 13:36:56 +00:00
print i
print ' ' unless i==l.last
end
end
2023-02-11 14:08:06 +00:00
else
2023-12-07 17:30:19 +00:00
abort "\x1B[1;31mERR\x1B[0m: Unknown option: #{ARGV.first}"
2023-02-10 19:02:43 +00:00
end