From 1148dea179580eed2962e39c0e062d661b0cce1e Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Sat, 6 Mar 2021 17:48:13 -0800 Subject: [PATCH 1/2] removed commandline reference --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 693b113..0353cd1 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,6 @@ This work is licenced via the [MIT Licence](http://www.dbad-license.org/). It is # Examples - -You can run the domino's pizza command line interface from your terminal just by running ` npm start `! See the example in the examples directory. - See the examples directory for simple apps and demonstrations on using the basic functionality. @@ -669,4 +666,4 @@ See the detailed docs on DominosErrors here : [DominosErrors.md](https://github. # Code, Order, Eat, Be Happy! -![Tatsu Ninja Turtles Go Play](https://media1.tenor.com/images/1e5eb7062aefb9fba304ca81ba877922/tenor.gif?itemid=7950001) \ No newline at end of file +![Tatsu Ninja Turtles Go Play](https://media1.tenor.com/images/1e5eb7062aefb9fba304ca81ba877922/tenor.gif?itemid=7950001) From 2898026a2af045241fb584a67dbef2e2a0bee495 Mon Sep 17 00:00:00 2001 From: Brandon Nozaki Miller Date: Sat, 6 Mar 2021 17:50:56 -0800 Subject: [PATCH 2/2] removed old commandline ordering interface --- .../dominos-commandline-pizza.js | 551 +----------------- 1 file changed, 2 insertions(+), 549 deletions(-) diff --git a/example/commandline-pizza/dominos-commandline-pizza.js b/example/commandline-pizza/dominos-commandline-pizza.js index 906950b..2e1b878 100644 --- a/example/commandline-pizza/dominos-commandline-pizza.js +++ b/example/commandline-pizza/dominos-commandline-pizza.js @@ -1,550 +1,3 @@ -var fs = require('fs'), - path = require('path'), - readline = require('readline'), - colors = require('colors'), - pizza = require('../../dominos-pizza-api.js'); +// cominog soon. -var util=require('util'); - -colors.setTheme( - { - menuItem : 'bgCyan', - menuTitle : 'bgBlue', - store : 'bgBlue', - info : 'cyan' - } -); - -var rl = readline.createInterface( - { - input: process.stdin, - output: process.stdout, - terminal:true - } -); -process.stdin.setEncoding('utf8'); - -readline.cursorTo(process.stdout, 0, 0); -readline.clearScreenDown(process.stdout); - -rl.setPrompt('Pizza> '); -rl.prompt(); - -var order=new pizza.Order(); - -rl.on( - 'line', - function(chunk) { - chunk=chunk.trim(); - - if (chunk !== null) { - chunk = chunk.replace( /\s\s+/g, ' ' ).trim(); - - var data = chunk.toLowerCase(); - - if(data.indexOf('find near ')>-1){ - findStores(data.slice(10)); - return; - } - - if(data.indexOf('find closest ')>-1){ - findStores(data.slice(data.indexOf('find closest ')+13),true); - return; - } - - if(data.indexOf('full menu for closest')>-1){ - findStores(data.slice(data.indexOf('full menu for closest')+21),true,false,true); - return; - } - - if(data.indexOf('menu for closest')>-1){ - findStores(data.slice(data.indexOf('menu for closest')+16),true,true); - return; - } - - if(data.indexOf('full menu for ')>-1){ - showMenu(data.slice(data.indexOf('full menu for ')+14)); - return; - } - - if(data.indexOf('menu for ')>-1){ - showMenu(data.slice(data.indexOf('menu for ')+9),true); - return; - } - - if(data.indexOf('order ')>-1){ - orderPizza(data.slice(data.indexOf('order ')+6),true); - return; - } - - if(data.indexOf('help')>-1){ - help(); - return; - } - - rl.prompt(); - } - } -); - -function help(){ - var commands=[ - 'find closest'.bgCyan+' {address info}'.info+' can be full or partial address city and state, postal code etc...', - 'find near'.bgCyan+' {address info}'.info+' can be full or partial address city and state, postal code etc...', - 'menu for closest'.bgCyan+' {address info}'.info+' can be full or partital address city and state, postal code etc...', - 'full menu for closest'.bgCyan+' {address info}'.info+' can be full or partial address city and state, postal code etc...', - 'menu for'.bgCyan+' {storeID}'.info+' get store id as part of a find closest or find near request', - 'full menu for'.bgCyan+' {storeID}'.info+' get store id as part of a find closest or find near request', - 'order'.bgCyan+' {comma deliminated list of item codes} \nexample:\norder PXC_14SCREEN, 2LSPRITE'.info+' !!!!get item codes from menu' - ]; - - for(var i in commands){ - console.log(commands[i]+'\n'); - } -} - - -/* - * pass in pizza info - * - */ - - -function showMenu(storeID,quick){ - console.log('Fetching menu for '+storeID.info+'...'); - order.StoreID=storeID - rl.prompt(); - - var store=new pizza.Store( - { - ID:storeID - } - ); - - store.getMenu( - function(menu){ - var data = menu.getRaw(); - if(quick){ - console.log( - '\n##########################\n'.blue, - 'Quick Menu'.yellow, - '\n##########################\n'.blue - ); - for(var i in data.result.PreconfiguredProducts){ - var item=data.result.PreconfiguredProducts[i]; - console.log( - '\n'.blue+ - ( - ( - item.Name.bold+' : '+ - item.Code+'\n' - ).menuTitle+ - item.Description+'\n'+ - item.Size - ).menuItem.white - ); - }; - - rl.prompt(); - return; - } - - console.log( - '\n##########################\n'.blue, - 'Full Menu'.yellow, - '\n##########################\n'.blue - ); - - var menuPortions=[ - 'Sides', - 'PreconfiguredProducts', - 'Products' - ]; - - for(var j in menuPortions){ - for(var i in data.result[menuPortions[j]]){ - if(!data.result[menuPortions[j]][i].Name){ - console.log( - ( - '=========='.cyan+ - i.blue+ - '=========='.cyan - ).bgYellow - ); - - for(var k in data.result[menuPortions[j]][i]){ - var item=data.result[menuPortions[j]][i][k]; - console.log( - '(+)'+( - ( - item.Name.bold+' : '+ - item.Code+'\n' - ).menuTitle+ - item.Description+'\n'+ - item.Size - ).menuItem.white - ); - } - continue; - } - var item=data.result[menuPortions[j]][i]; - console.log( - '(+)'+( - ( - item.Name.bold+' : '+ - item.Code+'\n' - ).menuTitle+ - item.Description+'\n'+ - item.Size - ).menuItem.white - ); - }; - } - rl.prompt(); - } - ); -} - -function validateAddress(address){ - var address=new pizza.Address(address); - pizza.Util.findNearbyStores( - address, - function(storeData){ - order.Address=storeData.result.Address; - if(!order.Address.Street){ - rl.question( - 'Not a valid address.'.red - +' if your having trouble, try using this format :\n'+'street, city, state, zip'.info+' with the commas.\n\n' - +'What is the full address for delivery? ', - validateAddress - ); - return; - } - - if(!order.StoreID){ - console.log( - 'You have not viewed any store\'s Menu, so you will get your order from the closest open store which delivers.\n' - +'And you\'ll like it!'.red - ); - } - - pizza.Util.findNearbyStores( - order.Address, - 'Delivery', - function(storeData){ - var openStores=[]; - - for(var i in storeData.result.Stores){ - if(storeData.result.Stores[i].IsOpen && - storeData.result.Stores[i].IsOnlineNow && - storeData.result.Stores[i].ServiceIsOpen.Delivery - ){ - order.StoreID=storeData.result.Stores[i].StoreID; - break; - } - } - - if(!order.StoreID){ - console.log('No Open Stores allowing delivery right now for the specified location'.bgRed.black.bold); - throw('NO PIZZA FOR YOU! Look at a menu next time!'); - return; - } - } - ); - - validateOrder(); - } - ); -} - -function findStores(address, closest, menu, fullMenu){ - if(!address){ - console.log('Need to know where to look, please provide atleast a zip code'); - rl.prompt(); - return; - } - console.log('Looking for stores near '+address.info+'...'); - rl.prompt(); - var nearAddress=new pizza.Address(address); - - if(!nearAddress.PostalCode){ - console.log('Not a valid address'.red+' you must at least provide a zipcode'); - return; - } - pizza.Util.findNearbyStores( - nearAddress, - 'Delivery', - function(storeData){ - var openStores=[]; - - order.Address=new pizza.Address(storeData.result.Address); - - for(var i in storeData.result.Stores){ - if(storeData.result.Stores[i].IsOpen && - storeData.result.Stores[i].IsOnlineNow && - storeData.result.Stores[i].ServiceIsOpen.Delivery - ){ - openStores.push(storeData.result.Stores[i]); - } - } - - if(openStores.length<1){ - console.log('No Open Stores allowing delivery right now for the specified location'.bgRed.black.bold); - return; - } - - var count=openStores.length; - - if(closest){ - count=1; - order.StoreID=openStores[0].StoreID - } - console.log('\n'); - for(var i=0; i