<commit_before>package install.task

import jaemisseo.man.configuration.annotation.type.Task
import jaemisseo.man.configuration.annotation.type.Undoable
import jaemisseo.man.configuration.annotation.Value
import install.util.TaskUtil
import jaemisseo.man.FileMan
import jaemisseo.man.QuestionMan
import install.bean.QuestionSetup
import jaemisseo.man.util.Util

/**
 * Created by sujkim on 2017-03-18.
 */
@Undoable
@Task
class QuestionFindFile extends TaskUtil{

    @Value
    QuestionSetup opt

    @Value("find.root.path")
    String searchRootPath

    @Value(name="find.file.name", required=true)
    String searchFileName

    @Value("find.result.edit.relpath")
    String editResultPath

    @Value(name='find.if', filter='parse')
    def searchIf



    @Override
    Integer run(){
        //Get Properties
        QuestionMan qman = new QuestionMan().setValidAnswer([undoSign, redoSign])
        if (opt.questionColor){
            qman.setBeforeQuestionClosure{
                config.logGen.setupConsoleLoggerColorPattern(opt.questionColor)
            }
            qman.setAfterQuestionClosure{
                config.logGen.setupBeforeConsoleLoggerPattern()
            }
        }

        List<File> itemList = []


        //Thread-Searcher - START
        logger.info " <Searching>"
        logger.info "Root Path: $searchRootPath"
        logger.info "File Name: $searchFileName"
        logger.info "Condition: $searchIf"
        logger.info ""

        Thread threadSearcher = Util.newThread(' <Stoped Searching>      '){
            List<File> foundFileList = FileMan.findAllWithProgressBar(searchRootPath, searchFileName, searchIf) { data ->
                File foundFile = data.item
                int count = data.count
                String editedPath = (editResultPath) ? FileMan.getFullPath(foundFile.path, editResultPath) : foundFile.path
                data.stringList << "  ${count}) ${editedPath}"
                itemList << new File(editedPath)
                return true
            }
            logger.info "${foundFileList.size()} was founded."
            logger.info " <Finished Searching>"
        }

        //Ask Question
        //Get Answer
        String yourAnswer
        try{
            yourAnswer = qman.question(opt){ String answer, jaemisseo.man.bean.QuestionSetup option ->
                if (answer.isNumber()){
                    int answerNum = Integer.parseInt(answer)
                    return (itemList.size() >= answerNum && answerNum >= 1)
                }
                return false
            }
        }catch(e){
            throw e
        }finally{<commit_msg>Update QuestionFindFile (you can add default result list)<commit_after>package install.task

import jaemisseo.man.configuration.annotation.type.Task
import jaemisseo.man.configuration.annotation.type.Undoable
import jaemisseo.man.configuration.annotation.Value
import install.util.TaskUtil
import jaemisseo.man.FileMan
import jaemisseo.man.QuestionMan
import install.bean.QuestionSetup
import jaemisseo.man.util.Util

/**
 * Created by sujkim on 2017-03-18.
 */
@Undoable
@Task
class QuestionFindFile extends TaskUtil{

    @Value
    QuestionSetup opt

    @Value("find.root.path")
    String searchRootPath

    @Value(name="find.file.name", required=true)
    String searchFileName

    @Value("find.result.default")
    List<String> resultDefaultList

    @Value("find.result.edit.relpath")
    String editResultPath

    @Value(name='find.if', filter='parse')
    def searchIf



    @Override
    Integer run(){
        //Get Properties
        QuestionMan qman = new QuestionMan().setValidAnswer([undoSign, redoSign])
        if (opt.questionColor){
            qman.setBeforeQuestionClosure{
                config.logGen.setupConsoleLoggerColorPattern(opt.questionColor)
            }
            qman.setAfterQuestionClosure{
                config.logGen.setupBeforeConsoleLoggerPattern()
            }
        }

        List<File> itemList = []


        //Thread-Searcher - START
        logger.info " <Searching>"
        logger.info "Root Path: $searchRootPath"
        logger.info "File Name: $searchFileName"
        logger.info "Condition: $searchIf"
        logger.info ""

        Thread threadSearcher = Util.newThread(' <Stoped Searching>      '){
            int defaultCount = 0
            List<File> foundFileList = FileMan.findAllWithProgressBar(searchRootPath, searchFileName, searchIf) { data ->
                File foundFile = data.item
                if (!data.stringList && resultDefaultList){
                    resultDefaultList.each{
                        data.stringList << "  ${++defaultCount}) ${it}"
                        itemList << new File(it)
                    }
                }
                int count = data.count + defaultCount
                String editedPath = (editResultPath) ? FileMan.getFullPath(foundFile.path, editResultPath) : foundFile.path
                data.stringList << "  ${count}) ${editedPath}"
                itemList << new File(editedPath)
                return true
            }
            logger.info "${foundFileList.size()} was founded."
            logger.info " <Finished Searching>"
        }

        //Ask Question
        //Get Answer
        String yourAnswer
        try{
            yourAnswer = qman.question(opt){ String answer, jaemisseo.man.bean.QuestionSetup option ->
                if (answer.isNumber()){
                    int answerNum = Integer.parseInt(answer)
                    return (itemList.size() >= answerNum && answerNum >= 1)
                }
                return false
            }
        }catch(e){
            throw e
        }finally{
{'fraction_non_alphanumeric': 0.09774040987913821, 'fraction_numerical': 0.003328078472587143, 'mean_word_length': 2.0798274002157497, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 22, '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': '4886398', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1496, 'n_words': 317}