diff --git a/lib/neocities/cli.rb b/lib/neocities/cli.rb index fa3a270..313d57e 100644 --- a/lib/neocities/cli.rb +++ b/lib/neocities/cli.rb @@ -309,16 +309,23 @@ def upload next end - if path.directory? - puts "#{path} is a directory, skipping (see the push command)" - next + if path.file? + files_to_upload = [path] + remote_paths = [['/', @dir, path.basename.to_s].join('/').gsub(%r{/+}, '/')] + else # directory + files_to_upload = path.glob("**/*").select(&:file?) + remote_paths = files_to_upload.map { |file| ['/', @dir, file.to_s].join('/').gsub(%r{/+}, '/') } end + + files_to_upload.count.times do |file_number| + file = files_to_upload[file_number] + remote_path = remote_paths[file_number] - remote_path = ['/', @dir, path.basename.to_s].join('/').gsub %r{/+}, '/' + puts @pastel.bold("Uploading #{file} to #{remote_path} ...") - puts @pastel.bold("Uploading #{path} to #{remote_path} ...") - resp = @client.upload path, remote_path - display_response resp + resp = @client.upload(file, remote_path) + display_response resp + end end end @@ -484,6 +491,10 @@ def display_upload_help_and_exit #{@pastel.green '$ neocities upload img.jpg img2.jpg'} Upload images to the root of your site #{@pastel.green '$ neocities upload -d images img.jpg'} Upload img.jpg to the 'images' directory on your site + + #{@pastel.green '$ neocities upload cats/'} Upload 'cats' folder on your site + + #{@pastel.green '$ neocities upload -d images cats/'} Upload 'cats' folder to the 'images' directory on your site (it will be cats/images/) HERE exit @@ -564,7 +575,7 @@ def display_help_and_exit puts <