From c7f6fa3bc11d9fe7d7119aaa650e7c246e257586 Mon Sep 17 00:00:00 2001 From: Rikuoh Date: Thu, 2 May 2024 08:14:25 +0900 Subject: [PATCH] -a --- ls.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ls.rb b/ls.rb index 362f733..5d99ab8 100644 --- a/ls.rb +++ b/ls.rb @@ -1,10 +1,6 @@ # frozen_string_literal: true require 'optparse' -opt = OptionParser.new -params = {} -opt.on('-a') { |x| params[:a] = x } -opt.parse(ARGV) COLUMNS = 3 @@ -16,11 +12,9 @@ def run end def list_filenames - if ARGV[0] - Dir.glob('*', File::FNM_DOTMATCH) - else - Dir.glob('*') - end + params = ARGV.getopts('a') + flags = params['a'] ? File::FNM_DOTMATCH : 0 + Dir.glob('*', flags) end def slice_filenames(listed_filenames)