forked from 2JaeSung/Cli_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
183 lines (136 loc) · 4.34 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env node
const commander = require("commander");
const lib = require("./lib");
if(process.argv.length <= 2){
console.log("Please type one or more keywords!");
process.exit(1);
}
function SeperatedList(value, dummyPrevious) {
return value.split(',');
}
let command_check = "";
let link_recipe = "";
let ingredients_recipe = "";
let food_check = "";
let diet_check = "";
let health_check = "";
let meal_check="";
commander
.command('link')
.description('This command links you to a website that has the information you need to make the recipe #No Options availalbe!')
.argument('<recipe>', 'Enter the recipe name')
.action(function() {
command_check = "link";
for(let i = 0; i < this.args.length; i++){
link_recipe = link_recipe + this.args[i] + " "
}
link_recipe = link_recipe.slice(0 , -1);
})
commander
.command('ingredients')
.description('This command shows a list of ingredients and how much you need to make the recipe you entered #No Options availalbe!')
.argument('<recipe>', 'Enter the recipe name')
.action(function() {
command_check = "ingredients";
for(let i = 0; i < this.args.length; i++){
ingredients_recipe = ingredients_recipe + this.args[i] + " "
}
ingredients_recipe = ingredients_recipe.slice(0, -1);
})
commander
.command('list')
.description('This command shows a list of what foods you can make with the ingredients you enter #You must enter -f Option!')
.requiredOption('-f, --food <food_list>', 'You must enter a list of ingredients seperated by "," ex) -f chicken,pepper', SeperatedList)
.option('-d, --diet <diet_info>', 'Enter the numbers given to put diet_info option {0 = balanced, 1 = high-fiber, 2 = high-protein, 3 = low-carb, 4 = low-fat, 5 = low-sodium} ex) -d 1')
.option('-h, --health <health_info>', 'Enter the numbers given to put health_info option {0 = alcohol-free, 1 = vegetarian, 2 = vegan, 3 = wheat-free, 4 = sugar-conscious, 5 = gluten-free, 6 = fish-free} ex) -h 2')
.option('-m, --meal <meal_type>', 'Enter the numbers given to put meal_type option {0 = Breakfast, 1 = Dinner, 2 = Launch, 3 = Snack, 4 = Teatime} ex) -m 3')
.action(function() {
command_check = "list";
food_check = this.opts().food;
diet_check = this.opts().diet;
health_check = this.opts().health;
meal_check = this.opts().meal;
})
commander.parse(process.argv);
if(command_check == "link") {
lib.link(link_recipe);
}
else if(command_check == "ingredients") {
lib.ingredient(ingredients_recipe);
}
else if(command_check == "list") {
let food = "";
let diet = "";
let health = "";
let meal = "";
for(let i = 0; i < food_check.length; i++) {
food = food + food_check[i] + " ";
}
switch(diet_check){
case "0":
diet = "balanced";
break;
case "1":
diet = "high-fiber";
break;
case "2":
diet = "high-protein";
break;
case "3":
diet = "low-carb";
break;
case "4":
diet = "low-fat";
break;
case "5":
diet = "low-sodium";
break;
default:
diet = 0;
}
switch(health_check){
case "0":
health = "alcohol-free";
break;
case "1":
health = "vegetarian";
break;
case "2":
health = "vegan";
break;
case "3":
health = "wheat-free";
break;
case "4":
health = "sugar-conscious";
break;
case "5":
health = "gluten-free";
break;
case "6":
health = "fish-free";
break;
default:
health = 0;
}
switch(meal_check){
case "0":
meal = "Breakfast";
break;
case "1":
meal = "Dinner";
break;
case "2":
meal = "Launch";
break;
case "3":
meal = "Snack";
break;
case "4":
meal = "Teatime";
break;
default:
meal = 0;
}
lib.recipes(food, diet, health, meal);
}