lib/softcover/commands/publisher.rb in softcover-0.9.6 vs lib/softcover/commands/publisher.rb in softcover-0.9.7
- old
+ new
@@ -87,10 +87,29 @@
def exit_with_message
puts "Processed #{current_book.processed_screencasts.size} screencasts."
end
- def unpublish!
+ def unpublish!(slug=nil)
+ require "rest_client"
+ require "softcover/client"
+
+ if slug.present?
+ begin
+ res = Softcover::Client.new.destroy_book_by_slug(slug)
+ if res["errors"]
+ puts "Errors: #{res.errors}"
+ return false
+ else
+ puts "Done!"
+ return true
+ end
+ rescue RestClient::ResourceNotFound
+ puts "Book with slug='#{slug}' not found under this account."
+ return false
+ end
+ end
+
return false unless current_book
if current_book.destroy
Softcover::BookConfig.remove
puts "Done!"
return true