#!/usr/bin/env lua dir = os.getenv("PWD") or io.popen("cd"):read() if not arg[1] then print("no argument, try again") return end require "R2H2" require "color" require "output_sizes" require "output_word" require "show_list" require "search_list" require "remove_word" require "add_word" require "edit_word" require "get_words" require "lessons" data_get = "heonian-content/words" data_output = "heonian-content/words" words = getWords(data_get) for _, v in pairs(arg) do if v == "-h" or v == "--help" or v == "--usage" or v == "--how" then please_help = true end end if arg[1] == "h" or arg[1] == "help" or arg[1] == "how" or arg[1] == "howdo" then print([[ [a]ll - shows all words in heonian. [e]dit - removes the word from the lexicon [h]elp - shows this message [l]esson - shows heonian lessons. [n]ew - add new word to the data [r]emove - removes the word from the lexicon [s]earch - searches all words and shows only those that return to string.find() [tr]anscript - transcripts the word to heonian script General parameters: -h / --help (shows what does the command do) ]]) return end if arg[1] == "a" or arg[1] == "all" then if please_help then print([[ [a]ll - shows all words in heonian. Parameters: -h / --help (shows what does the command do) -a / --all (shows more info on the word, if any) ]]) else showList() end return end if arg[1] == "s" or arg[1] == "search" then if please_help then print([[ [s]earch - searches all words and shows only those that return to string.find() Parameters: -h / --help (shows what does the command do) -a / --all (shows more info on the word, if any) -e / --english (limits the search to the translated words) -r / --raw (limits the search to the heonian words) -i / --id (searches using word id) ]]) else if arg[2] then searchList(arg[2]) else print("no query to search") end end return end if arg[1] == "l" or arg[1] == "lesson" then if please_help then print([[ [l]esson - shows heonian lessons. if no lesson is specified, lists all the lessons. Parameters: -h / --help (shows what does the command do) ]]) else if arg[2] then lesson(arg[2]) else print("specify a lesson",table.unpack(getFormattedLessonNames(dir.."/heonian-content/lessons/"))) end end return end if arg[1] == "tr" or arg[1] == "transcript" then if please_help then print([[ [tr]anscript - transcripts the word to heonian script Parameters: -h / --help (shows what does the command do) -v / --verbose (shows the transcription process) -c / --copy (copies transcription to keyboard) ]]) else if arg[2] then print(convertToHeonian(arg[2])) else print("no string to transcript") end return end end if arg[1] == "r" or arg[1] == "remove" then if please_help then print([[ [r]emove - removes the word from the lexicon Parameters: -h / --help (shows what does the command do) ]]) else if arg[2] and tonumber(arg[2]) <= #words and tonumber(arg[2]) > 0 then removeWord(arg[2]) else print("no word to remove") end return end end if arg[1] == "n" or arg[1] == "new" then if please_help then print([[ [n]ew - add new word to the data Parameters: -h / --help (shows what does the command do) ]]) else addWord() end end if arg[1] == "e" or arg[1] == "edit" then if please_help then print([[ [e]dit - removes the word from the lexicon Parameters: -h / --help / (shows what does the command do) -mph / --modify-phonetics / edit the phonetics field -mm / --modify-meaning / edit the meaning field -mt / --modify-type / edit the type field -mco / --modify-canon-origin / edit the canon origin field -mmo / --modify-meta-origin / edit the meta origin field -mn / --modify-notes / edit the notes field -ma / --modify-all / edit all the fields (-ma is enabled by default, disabled if other flags) ]]) else if arg[2] and tonumber(arg[2]) <= #words and tonumber(arg[2]) > 0 then editWord(arg[2]) else print("no word to edit") end return end end