<commit_before>class Cask::CLI::List < Cask::CLI::Base
  def self.run(*arguments)
    @options = Hash.new
    @options[:one] = true if arguments.delete('-1')
    if arguments.any?
      retval = list_casks(*arguments)
    else
      retval = list_installed
    end
    # retval is ternary: true/false/nil
    if retval.nil? and not arguments.any?
      opoo "nothing to list"  # special case: avoid exit code
    elsif retval.nil?
      raise CaskError.new("nothing to list")
    elsif ! retval
      raise CaskError.new("listing incomplete")
    end
  end

  def self.list_casks(*cask_names)
    count = 0
    cask_names.each do |cask_name|
      odebug "Listing files for Cask #{cask_name}"
      cask = Cask.load(cask_name)
      if cask.installed?
        count += 1
        list_artifacts(cask)
        list_files(cask)
      else
        opoo "#{cask} is not installed"
      end
    end
    count == 0 ? nil : count == cask_names.length
  end

  def self.list_artifacts(cask)
    artifacts = Cask::Artifact.for_cask(cask)
    artifacts.each do |artifact|
      summary = artifact.new(cask).summary
      ohai summary[:english_description], summary[:contents] unless summary.empty?
    end
  end

  def self.list_files(cask)
    ohai "Raw contents of Cask directory:"
    Cask::PrettyListing.new(cask).print
  end

  def self.list_installed
    installed_casks = Cask.installed
    columns = installed_casks.map(&:to_s)
    if @options[:one]
      puts columns
    else
      puts_columns columns
    end
    columns.empty? ? nil : installed_casks.length == columns.length
  end

  def self.help
    "with no args, lists installed casks; given installed casks, lists installed files"
  end
end<commit_msg>Add support for long format in list command<commit_after>class Cask::CLI::List < Cask::CLI::Base
  def self.run(*arguments)
    @options = Hash.new
    @options[:one] = true if arguments.delete('-1')
    @options[:long] = true if arguments.delete('-l')

    if arguments.any?
      retval = list_casks(*arguments)
    else
      retval = list_installed
    end
    # retval is ternary: true/false/nil
    if retval.nil? and not arguments.any?
      opoo "nothing to list"  # special case: avoid exit code
    elsif retval.nil?
      raise CaskError.new("nothing to list")
    elsif ! retval
      raise CaskError.new("listing incomplete")
    end
  end

  def self.list_casks(*cask_names)
    count = 0
    cask_names.each do |cask_name|
      odebug "Listing files for Cask #{cask_name}"
      cask = Cask.load(cask_name)
      if cask.installed?
        count += 1
        list_artifacts(cask)
        list_files(cask)
      else
        opoo "#{cask} is not installed"
      end
    end
    count == 0 ? nil : count == cask_names.length
  end

  def self.list_artifacts(cask)
    artifacts = Cask::Artifact.for_cask(cask)
    artifacts.each do |artifact|
      summary = artifact.new(cask).summary
      ohai summary[:english_description], summary[:contents] unless summary.empty?
    end
  end

  def self.list_files(cask)
    ohai "Raw contents of Cask directory:"
    Cask::PrettyListing.new(cask).print
  end

  def self.list_installed
    installed_casks = Cask.installed
    columns = installed_casks.map(&:to_s)
    if @options[:one]
      puts columns
    elsif @options[:long]
      puts Cask::SystemCommand.run!("/bin/ls", :args => ["-l", Cask.caskroom])
    else
      puts_columns columns
    end
    columns.empty? ? nil : installed_casks.length == columns.length
  end

  def self.help
    "with no args, lists installed casks; given installed casks, lists installed files"
  end
end
{'fraction_non_alphanumeric': 0.10080310163389643, 'fraction_numerical': 0.002215452783162559, 'mean_word_length': 2.8303287380699893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6498300', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1180, 'n_words': 309}