<commit_before>require 'thor'
require 'hiptask/list'
require 'hiptask/version'
require 'yaml'

module Hiptask

    class CLI < Thor

        include Thor::Shell

        default_task :list


        @@config = {}
        @@config_file = ENV['HOME'] + '/.hiptask/config.yml'
        @@tasks_file = ENV['HOME'] + '/.hiptask/tasks.txt'
        @@message = nil


        def self.start(argv)

            # Config
            config_dir = File.dirname(@@config_file)
            Dir.mkdir(config_dir) unless Dir.exists? config_dir
            unless File.exists? @@config_file
                file = File.open(@@config_file, "w+") { |file |
                    file.puts "tasks_file: " + @@tasks_file
                }
            end
            @@config = YAML::load_file(@@config_file)
            @@tasks_file = @@config['tasks_file'] if @@config['tasks_file']

            # Environment
            @@list = List.new(@@tasks_file)

            super argv

        end


        desc "config [ACTION] [KEY] [VAL]", "Get a config variable"
        def config(action=nil, key=nil, value=nil)
            case action
                when 'get'
                    puts @@config[key]
                when 'set'
                    if value
                        @@config[key] = value
                        puts key + ' = ' + value.to_s
                    else
                        @@config.delete(key) unless value
                        puts "deleted " + key
                    end
                    File.open(@@config_file, "w") { |file|
                        YAML.dump(@@config, file)
                    }
                when 'delete'
                    puts "deleted " + key
                    @@config.delete(key)
                    File.open(@@config_file, "w") { |file|
                        YAML.dump(@@config, file)
                    }
                else
                    puts @@config
                end
        end


        desc "list", "Display your task list"
        def list()

            say "\n"
            if @@message
                say "  [ #{@@message} ]\n", Color::GREEN
                return
            end

            say "  #{@@list.items.length} Items", Color::GREEN
            say "\n"
            if @@list.items.length > 0
                @@list.items.each_with_index { |item, index|
                    index = index + 1
                    say "  #{index.to_s.ljust(2)}", Color::YELLOW
                    if item.start_with? ">"
                        say " [x] "
                        say "#{item[1, item.length - 1]}"
                    else
                        say " [ ] "
                        say "#{item}"
                    end
                }
            else
                say "  Add a new task with: hiptask add \"Get milk\"", Color::YELLOW
            end
            puts " "

        end


        desc "add CONTENT", "Add a new task"
        def add(content)
            @@list.add(content)
            @@message = "Task #{@@list.items.length - 1} was created"
            list
        end

<commit_msg>No more newlines when in double digit tasks<commit_after>require 'thor'
require 'hiptask/list'
require 'hiptask/version'
require 'yaml'

module Hiptask

    class CLI < Thor

        include Thor::Shell

        default_task :list


        @@config = {}
        @@config_file = ENV['HOME'] + '/.hiptask/config.yml'
        @@tasks_file = ENV['HOME'] + '/.hiptask/tasks.txt'
        @@message = nil


        def self.start(argv)

            # Config
            config_dir = File.dirname(@@config_file)
            Dir.mkdir(config_dir) unless Dir.exists? config_dir
            unless File.exists? @@config_file
                file = File.open(@@config_file, "w+") { |file |
                    file.puts "tasks_file: " + @@tasks_file
                }
            end
            @@config = YAML::load_file(@@config_file)
            @@tasks_file = @@config['tasks_file'] if @@config['tasks_file']

            # Environment
            @@list = List.new(@@tasks_file)

            super argv

        end


        desc "config [ACTION] [KEY] [VAL]", "Get a config variable"
        def config(action=nil, key=nil, value=nil)
            case action
                when 'get'
                    puts @@config[key]
                when 'set'
                    if value
                        @@config[key] = value
                        puts key + ' = ' + value.to_s
                    else
                        @@config.delete(key) unless value
                        puts "deleted " + key
                    end
                    File.open(@@config_file, "w") { |file|
                        YAML.dump(@@config, file)
                    }
                when 'delete'
                    puts "deleted " + key
                    @@config.delete(key)
                    File.open(@@config_file, "w") { |file|
                        YAML.dump(@@config, file)
                    }
                else
                    puts @@config
                end
        end


        desc "list", "Display your task list"
        def list()

            say "\n"
            if @@message
                say "  [ #{@@message} ]\n", Color::GREEN
                return
            end

            say "  #{@@list.items.length} Items", Color::GREEN
            say "\n"
            if @@list.items.length > 0
                @@list.items.each_with_index { |item, index|
                    index = index + 1
                    say "  #{index.to_s.ljust(3)}", Color::YELLOW
                    if item.start_with? ">"
                        say " [x] "
                        say "#{item[1, item.length - 1]}"
                    else
                        say " [ ] "
                        say "#{item}"
                    end
                }
            else
                say "  Add a new task with: hiptask add \"Get milk\"", Color::YELLOW
            end
            puts " "

        end


        desc "add CONTENT", "Add a new task"
        def add(content)
            @@list.add(content)
            @@message = "Task #{@@list.items.length - 1} was created"
            list
        end


{'fraction_non_alphanumeric': 0.11311053984575835, 'fraction_numerical': 0.0019280205655526992, 'mean_word_length': 1.0531002638522426, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6393081', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1603, 'n_words': 401}