<commit_before>require 'docopt'
require 'colorize'
require 'reel/version'
require 'reel/bundle'
require 'pathname'

module Reel
  @app = File.basename(__FILE__).chomp('.rb')

  # TODO: why is .undent not working??
  @doc = <<DOCOPT
#{@app.blue}

Copyright (C) 2015 <NAME> https://github.com/mkwmms

#{'Usage:'.blue}
  #{@app} [options] bundle REPO ...
  #{@app} [options] update [REPO ...]

#{'Arguements:'.blue}
  REPO  The GitHub repo (in the form mkwmms/reel or full URL) to download

#{'Options:'.blue}
  -h --help     show this help message and exit
  -V --version  show version and exit
  -q --quiet    suppress output from Git etc.
DOCOPT

  def self.verbose?
    @args['--quiet'] == false || @args.nil? ? true : false
  end

  def self.reel_config_home
    config_dir = ENV.fetch('XDG_CONFIG_HOME', Dir.home)
    env_config_dir = ENV.fetch('REEL_CONFIG_HOME')
    if env_config_dir
      env_config_dir
    elsif config_dir == Dir.home
      File.join(config_dir, '.config', 'reel')
    else
      File.join(config_dir, 'reel')
    end
  end

  def self.parse_cli
    version_msg = "#{@app} #{Reel::VERSION}"
    @args = Docopt.docopt(@doc, version: version_msg)
    puts @args
    if @args['bundle']
      prefix = reel_config_home
      FileUtils.mkdir_p prefix
      bundle = Reel::Bundle.new(prefix, @args['REPO'])
      bundle.download
    end
  rescue Docopt::Exit, RegexpError => e
    puts e.message
  end
end

# TODO: add options for parsing a file containing repos
# TODO: implement downloading a regular URL
# TODO: add fish, zsh, and bash support (link and/or source files)
# TODO: test<commit_msg>Change TODO format to inlcude :<commit_after>require 'docopt'
require 'colorize'
require 'reel/version'
require 'reel/bundle'
require 'pathname'

module Reel
  @app = File.basename(__FILE__).chomp('.rb')

  # TODO: why is .undent not working??
  @doc = <<DOCOPT
#{@app.blue}

Copyright (C) 2015 <NAME> https://github.com/mkwmms

#{'Usage:'.blue}
  #{@app} [options] bundle REPO ...
  #{@app} [options] update [REPO ...]

#{'Arguements:'.blue}
  REPO  The GitHub repo (in the form mkwmms/reel or full URL) to download

#{'Options:'.blue}
  -h --help     show this help message and exit
  -V --version  show version and exit
  -q --quiet    suppress output from Git etc.
DOCOPT

  def self.verbose?
    @args['--quiet'] == false || @args.nil? ? true : false
  end

  def self.reel_config_home
    config_dir = ENV.fetch('XDG_CONFIG_HOME', Dir.home)
    env_config_dir = ENV.fetch('REEL_CONFIG_HOME')
    if env_config_dir
      env_config_dir
    elsif config_dir == Dir.home
      File.join(config_dir, '.config', 'reel')
    else
      File.join(config_dir, 'reel')
    end
  end

  def self.parse_cli
    version_msg = "#{@app} #{Reel::VERSION}"
    @args = Docopt.docopt(@doc, version: version_msg)
    puts @args
    if @args['bundle']
      prefix = reel_config_home
      FileUtils.mkdir_p prefix
      bundle = Reel::Bundle.new(prefix, @args['REPO'])
      bundle.download
    end
  rescue Docopt::Exit, RegexpError => e
    puts e.message
  end
end

# TODO: add options for parsing a file containing repos
# TODO: implement downloading a regular URL
# TODO: add fish, zsh, and bash support (link and/or source files)
# TODO: lkaslkdfasdlf
{'fraction_non_alphanumeric': 0.13269996935335582, 'fraction_numerical': 0.002451731535396874, 'mean_word_length': 3.3060686015831133, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1112468', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1141, 'n_words': 326}