Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions lib/neocities/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/<your files>)

HERE
exit
Expand Down Expand Up @@ -564,7 +575,7 @@ def display_help_and_exit
puts <<HERE
#{@pastel.dim 'Subcommands:'}
push Recursively upload a local directory to your site
upload Upload individual files to your Neocities site
upload Upload specific files/directories to your Neocities site
delete Delete files from your Neocities site
list List files from your Neocities site
info Information and stats for your site
Expand Down