<commit_before>require 'simpleconsole'
require 'hirb'
require 'highline/import'
require 'osx_keychain'

require 'github/downloads'
require 'github/s3_uploader'

module Github
  class DownloadsController < SimpleConsole::Controller
    include Hirb::Console
    
    params :string => { 
      :u => :user, 
      :f => :file, 
      :n => :name, 
      :r => :repos,
      :d => :description,
      :p => :proxy
    }, 
    :bool => {
      :o => :overwrite
    }
        
    before_filter :set_proxy
    
    def default
      puts "Valid actions: list, upload, delete"
      exit 1
    end
    
    def list
      if (downloads = github.list)
        table downloads, {:fields => [:name, :description, :download_count]}
      else
        puts "Couldn't fetch downloads!"
      end
    rescue Github::Downloads::UnexpectedResponse => e
      fail! "Unexpected response (#{e.response})."
    end
    
    def create
      if params[:file].nil?
        fail! "* A file must be specified (-f or --file)"
      end

      if (url_for_upload = github(:authenticated).create(params[:file], params[:description]))
        puts "Upload successful! (#{url_for_upload})"
      else
        fail! "Upload failed!"
      end
    rescue Github::Downloads::UnexpectedResponse => e
      fail! "Unexpected response (#{e.response})."
    end
    
    private
    
    def fail!(message, status = 1)
      puts(message)
      exit(status)
    end<commit_msg>It seems that even the list action needs authentication<commit_after>require 'simpleconsole'
require 'hirb'
require 'highline/import'
require 'osx_keychain'

require 'github/downloads'
require 'github/s3_uploader'

module Github
  class DownloadsController < SimpleConsole::Controller
    include Hirb::Console
    
    params :string => { 
      :u => :user, 
      :f => :file, 
      :n => :name, 
      :r => :repos,
      :d => :description,
      :p => :proxy
    }, 
    :bool => {
      :o => :overwrite
    }
        
    before_filter :set_proxy
    
    def default
      puts "Valid actions: list, upload, delete"
      exit 1
    end
    
    def list
      if (downloads = github(:authenticated).list)
        table downloads, {:fields => [:name, :description, :download_count]}
      else
        puts "Couldn't fetch downloads!"
      end
    rescue Github::Downloads::UnexpectedResponse => e
      fail! "Unexpected response (#{e.response})."
    end
    
    def create
      if params[:file].nil?
        fail! "* A file must be specified (-f or --file)"
      end

      if (url_for_upload = github(:authenticated).create(params[:file], params[:description]))
        puts "Upload successful! (#{url_for_upload})"
      else
        fail! "Upload failed!"
      end
    rescue Github::Downloads::UnexpectedResponse => e
      fail! "Unexpected response (#{e.response})."
    end
    
    private
    
    def fail!(message, status = 1)
      puts(message)
      exit(status)
    end
{'fraction_non_alphanumeric': 0.12118126272912423, 'fraction_numerical': 0.002036659877800407, 'mean_word_length': 2.368, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '108483', 'n_tokens_mistral': 899, 'n_tokens_neox': 877, 'n_words': 241}