# File lib/chef/knife/cookbook_site_share.rb, line 36
      def run
        if @name_args.length < 2
          show_usage
          Chef::Log.fatal("You must specify the cookbook name and the category you want to share this cookbook to.")
          exit 1
        end

        cookbook_name = @name_args[0]
        category = @name_args[1]
        cl = Chef::CookbookLoader.new
        if cl.cookbook_exists?(cookbook_name)
          cookbook = cl[cookbook_name]
          Chef::CookbookUploader.validate_cookbook(cookbook)
          tmp_cookbook_dir = Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
          begin
            Chef::Log.debug("temp cookbook directory is #{tmp_cookbook_dir.inspect}")
            Chef::Log.info("Making tarball #{cookbook_name}.tgz")
            Chef::Mixin::Command.run_command(:command => "tar -czf #{cookbook_name}.tgz #{cookbook_name}", :cwd => tmp_cookbook_dir)
          rescue => e
            Chef::Log.error("Error making tarball #{cookbook_name}.tgz: #{e.message}. Set log level to debug (-l debug) for more information.")
            Chef::Log.debug("\n#{e.backtrace.join("\n")}")
            exit(1)
          end

          begin
            do_upload("#{tmp_cookbook_dir}/#{cookbook_name}.tgz", category, Chef::Config[:node_name], Chef::Config[:client_key])
            Chef::Log.info("Upload complete!")
            Chef::Log.debug("Removing local staging directory at #{tmp_cookbook_dir}")
            FileUtils.rm_rf tmp_cookbook_dir
          rescue => e
            Chef::Log.error("Error uploading cookbook #{cookbook_name} to the Opscode Cookbook Site: #{e.message}. Set log level to debug (-l debug) for more information.")
            Chef::Log.debug("\n#{e.backtrace.join("\n")}")
            exit(1)
          end

        else
          Chef::Log.error("Could not find cookbook #{cookbook_name} in your cookbook path.")
          exit(1)
        end

      end