neocities / neocities-ruby

The Neocities Gem - A CLI and library for using the Neocities web site API.
https://neocities.org
51 stars 14 forks source link

Empty user input not handled in `push`. #36

Closed AndrewDemidov closed 3 months ago

AndrewDemidov commented 2 years ago

Executing neocities push --dry-run results in a TypeError after printing "Doing a dry run, not actually pushing anything". From the looks of it, line 181 in "https://github.com/neocities/neocities-ruby/blob/master/lib/neocities/cli.rb" is at fault:

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/neocities-0.0.17/lib/neocities/cli.rb:181:in initialize': no implicit conversion of nil into String (TypeError) from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/neocities-0.0.17/lib/neocities/cli.rb:181:inPathname' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/neocities-0.0.17/lib/neocities/cli.rb:181:in push' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/neocities-0.0.17/lib/neocities/cli.rb:79:inrun' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/neocities-0.0.17/bin/neocities:4:in <top (required)>' from C:/Ruby31-x64/bin/neocities:32:inload' from C:/Ruby31-x64/bin/neocities:32:in `

'

Line 181: root_path = Pathname @subargs[0]

It seemingly expects something at 0 in @subargs, but, as can be acquired from a loop earlier, shift is performed. Thus nil. Appending something surely helps: neocities push --dry-run .. But incorrect (empty) user input should be handled!