For this, we'll use the command in a child process: Now that we have the phrase, we need to copy it to the clipboard. Math.floor( Math.random() * 1000 ) % filteredPhrases.length Now, let's generate a random index from the array. Only include the phrase if the filter matches. Create a list of filtered phrases for the given tag. phrases first, then we'll select them. random phrase from a pool of phrases, let's factor out the Exit out of the process (as a failure). Util.puts( "Use: -general, -sappy, -naughty, -playful" ) If we could not figure out what the command-line argument was, Check to see if the use has supplied a filter. Var filterArgument = (process.argv || "") we'll be selecting from all of the phrases. need to filter the list using a command-line argument. Now that we have our phrase library populated, let's see if we Text: "I wanna dip you in pudding and eat you for dessert!", Text: "I was just thinking of you and it made me smile :)", Text: "I can't stop thinking about your body!", Text: "Hey shmoopy, I miss you.", // For Seinfeld fans. Text: "I love you more than a kitten loves milk!", Text: "Sometimes, I have to pinch myself, I'm so happy with you!", Create some tags to be used for filtering. phrase can be tagged for use in command-line filtering. Build up a list of loving things to say to your loved one. Var childProcess = require( "child_process" ) this to execute the "copy to clipboard" command. Include the library for spinning up child processes. Include the system utility library (for output). ^- interpretor (which was installed in the local BIN directory For our purposes, we'll be using the Node.js ^- Tell the terminal which interpreter to use for the execution
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |