This commit is contained in:
Rikuoh Tsujitani 2024-04-29 10:23:04 +09:00
parent 246800ddb1
commit cb68ba2b41
Signed by: riq0h
GPG key ID: 010F09DEA298C717

29
ls.rb
View file

@ -1,25 +1,10 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'optparse' require 'optparse'
opt = OptionParser.new
def options params = {}
secret_files = {} opt.on('-a') { |x| params[:a] = x }
opt = OptionParser.new opt.parse(ARGV)
opt.on('-a') { |v| params[:a] = v }
opt.on('-r') { |v| params[:r] = v }
secret_files[:dir] = opt.parse!(ARGV)[0]
secret_files
end
SELECTED = options
def get_files(option_a: false)
if option_a
Dir.glob('*', File::FNM_DOTMATCH, base: SELECTED[:dir])
else
Dir.glob('*', base: SELECTED[:dir])
end
end
COLUMNS = 3 COLUMNS = 3
@ -31,7 +16,11 @@ def run
end end
def list_filenames def list_filenames
Dir.glob('*') if ARGV[0]
Dir.glob('*', File::FNM_DOTMATCH)
else
Dir.glob('*')
end
end end
def slice_filenames(listed_filenames) def slice_filenames(listed_filenames)