<commit_before>require 'thor'
require 'kosi'

module WorkGuide
  class CLI < Thor
    desc "add [guide description]", "Add a new guide"
    option :cycle, default: 'daily', banner: '[hourly|daily|weekly|monthly]', aliases: :c
    def add(description)
      guide = Guide.create(
        description: description,
        cycle: options[:cycle]
      )
      puts "Created [#{Guide.all.size - 1}]#{guide}"
    end

    desc "update [index]", "Edit a guide"
    option :priority, default: 'medium', banner: '[high|medium|low]'
    def update(index)
      guide = Guide.all[index.to_i]
      guide.priority = options[:priority] if options[:priority]
      Guide.save
      puts "Update [#{index}]#{guide}"
    end

    desc "list", "List guides"
    option :all, type: :boolean, default: false, aliases: :a
    def list
      table = Kosi::Table.new(
        header: %w(index cycle priorify description done_at)
      )

      rows = Guide.all.map.with_index { |guide, index|
        [index, guide]
      }.select { |index, guide|
        options[:all] || guide.should_do?
      }.sort_by { |index, guide|
        guide.priority_rate
      }.map { |index, guide|
        [index, guide.cycle, guide.priority, guide.description, guide.done_at]
      }

      puts table.render(rows)
    end

    desc "delete [index]", "Delete a guide"
    def delete(index)
      guide = Guide.all.delete_at(index.to_i)
      Guide.save
      puts "Deleted [#{index}]#{guide}"
    end

    desc "done [index]", "Mark as done"
    option :at, banner: "done_at"
    def done(index)
      guide = Guide.all[index.to_i]
      guide.done_at =
        if options[:at]
          Time.parse(options[:at])
        else
          Time.now
        end

      Guide.save
      puts "Done [#{index}]#{guide}"
    end
  end
end<commit_msg>Allow more than one index to done guide<commit_after>require 'thor'
require 'kosi'

module WorkGuide
  class CLI < Thor
    desc "add [guide description]", "Add a new guide"
    option :cycle, default: 'daily', banner: '[hourly|daily|weekly|monthly]', aliases: :c
    def add(description)
      guide = Guide.create(
        description: description,
        cycle: options[:cycle]
      )
      puts "Created [#{Guide.all.size - 1}]#{guide}"
    end

    desc "update [index]", "Edit a guide"
    option :priority, default: 'medium', banner: '[high|medium|low]'
    def update(index)
      guide = Guide.all[index.to_i]
      guide.priority = options[:priority] if options[:priority]
      Guide.save
      puts "Update [#{index}]#{guide}"
    end

    desc "list", "List guides"
    option :all, type: :boolean, default: false, aliases: :a
    def list
      table = Kosi::Table.new(
        header: %w(index cycle priorify description done_at)
      )

      rows = Guide.all.map.with_index { |guide, index|
        [index, guide]
      }.select { |index, guide|
        options[:all] || guide.should_do?
      }.sort_by { |index, guide|
        guide.priority_rate
      }.map { |index, guide|
        [index, guide.cycle, guide.priority, guide.description, guide.done_at]
      }

      puts table.render(rows)
    end

    desc "delete [index]", "Delete a guide"
    def delete(index)
      guide = Guide.all.delete_at(index.to_i)
      Guide.save
      puts "Deleted [#{index}]#{guide}"
    end

    desc "done [index]", "Mark as done"
    option :at, banner: "done_at"
    def done(*indexes)
      guides = indexes.map { |index| Guide.all[index.to_i] }
      done_at =
        if options[:at]
          Time.parse(options[:at])
        else
          Time.now
        end

      guides.each do |guide|
        guide.done_at = done_at
      end

      Guide.save
      indexes.each do |index|
        puts "Done [#{index}]#{Guide.all[index.to_i]}"
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13444268357105124, 'fraction_numerical': 0.0005282620179609086, 'mean_word_length': 2.4147880973850318, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '473714', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1207, 'n_words': 326}