<commit_before>require "nowhen"
require "args_parser"

module NoWhen
  module Command
    def self.show_help(parser)
        STDERR.puts "nowhen - Tagger for LifeLog v#{NoWhen::VERSION}"
        STDERR.puts "         https://github.com/shokai/nowhen"
        STDERR.puts parser.help
        STDERR.puts
        STDERR.puts "e.g."
        STDERR.puts "  % now yummy"
        STDERR.puts "  % when yummy"
    end

    def self.now(argv)
      parser = ArgsParser.parse argv do
        arg :version, 'show version', :alias => :v
        arg :help, 'show help', :alias => :h
      end
      if parser.has_option? :help
        show_help parser
      elsif parser.has_option? :version
        STDERR.puts "nowhen version #{NoWhen::VERSION}"
      elsif !parser.argv.empty?
        what = parser.argv[0].strip
        tag = NoWhen::Model::Tag.new(:what => what)
        tag.save
        puts tag
      else
        show_help parser
      end
    end

    def self.when(argv)
      parser = ArgsParser.parse argv do
        arg :version, 'show version', :alias => :v
        arg :help, 'show help', :alias => :h
      end
      if parser.has_option? :help
        show_help parser
      elsif parser.has_option? :version
        STDERR.puts "nowhen version #{NoWhen::VERSION}"
      else
        query = parser.argv.empty? ? {} : {:what => parser.argv[0].strip}
        tags = NoWhen::Model::Tag.find query
        tags.each do |tag|
          puts tag
        end
      end
    end
  end
end<commit_msg>set when command results by --limit<commit_after>require "nowhen"
require "args_parser"

module NoWhen
  module Command
    def self.show_help(parser)
        STDERR.puts "nowhen - Tagger for LifeLog v#{NoWhen::VERSION}"
        STDERR.puts "         https://github.com/shokai/nowhen"
        STDERR.puts parser.help
        STDERR.puts
        STDERR.puts "e.g."
        STDERR.puts "  % now yummy"
        STDERR.puts "  % when yummy"
    end

    def self.now(argv)
      parser = ArgsParser.parse argv do
        arg :version, 'show version', :alias => :v
        arg :help, 'show help', :alias => :h
      end
      if parser.has_option? :help
        show_help parser
      elsif parser.has_option? :version
        STDERR.puts "nowhen version #{NoWhen::VERSION}"
      elsif !parser.argv.empty?
        what = parser.argv[0].strip
        tag = NoWhen::Model::Tag.new(:what => what)
        tag.save
        puts tag
      else
        show_help parser
      end
    end

    def self.when(argv)
      parser = ArgsParser.parse argv do
        arg :limit, 'tags count', :default => 40
        arg :version, 'show version', :alias => :v
        arg :help, 'show help', :alias => :h
      end
      if parser.has_option? :help
        show_help parser
      elsif parser.has_option? :version
        STDERR.puts "nowhen version #{NoWhen::VERSION}"
      else
        query = {}
        query[:what] = parser.argv[0].strip unless parser.argv.empty?
        query[:limit] = parser[:limit]
        tags = NoWhen::Model::Tag.find query
        tags.each do |tag|
          puts tag
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11029176017954473, 'fraction_numerical': 0.0019236934915036871, 'mean_word_length': 1.9686013320647002, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '1266825', 'n_tokens_mistral': 1001, 'n_tokens_neox': 985, 'n_words': 263}