# Create Program Mini Coffe With Command Line: Node Js & Default Terminal Ubuntu

Assalamualaikum, hello guys welcome back to my blog today we are learning about program mini coffe with command line , in this tutorial i use: terminal ubuntu and node js, let’s me show about tutorial

# 1\. Create Ingredients

first we need for folder coffe shop, you can typing this

```bash
--create & open folder--
mkdir coffe-shop
cd coffe-shop

--initial--
npm init
```

then you can use npm init for give you `package.json`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1757377701807/f293bdc7-93eb-476a-90ae-524cf2fbb9cb.png align="center")

then you can edit in folder package.json

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1757467013516/495f189a-aa41-4a40-b286-875ad3bcc9e3.png align="center")

then you can create new file in folder `coffe-shop`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1757378493222/5dfd7b29-5b30-4629-8d4b-589f285ce5d9.png align="center")

# 2\. Create Service

In this segmen we will create code every file in direcotory

```bash
import promptSync from "prompt-sync";
import makeCoffee from "./menu/create-coffe.js";
import makeTea from "./menu/create-tea.js"
import makeFriedRice from "./menu/create-fried-rice.js"
import makeGrilledChicken from "./menu/create-grilled-chiken.js"

const prompt = promptSync({ sigint: true });

function showMenu() {
  console.log("\n=== WARUNG SERVICES ===");
  console.log("1) Make Coffee");
  console.log("2) Make Tea        (please create the module)");
  console.log("3) Fried Rice      (please create the module)");
  console.log("4) Grilled Chicken (please create the module)");
  console.log("0) Close Shop");
}

function askNumber(label, def = 0) {
  const txt = prompt(`${label} (default ${def}): `).trim();
  const num = txt === "" ? def : Number(txt);
  return Number.isNaN(num) ? def : num;
}

function askBoolean(label, def = false) {
  const txt = prompt(`${label} (y/n, default ${def ? "y" : "n"}): `)
    .trim()
    .toLowerCase();
  if (txt === "") return def;
  return txt === "y" || txt === "yes";
}

function coffeeService() {
  console.log("\n— Coffee Menu —");
  const cups = askNumber("How many cups", 1);
  const sugar = askNumber("Sugar (tsp per cup)", 1);
  const withMilk = askBoolean("With milk?", false);
  const result = makeCoffee({ cups, sugar, withMilk });
  console.log("\n" + result + "\n");
}

function teaService() {
  console.log("\n— Tea Menu —");
  const cups = askNumber("How many cups", 1);
  const sugar = askNumber("Sugar (tsp per cup)", 1);
  const teaBag = askBoolean("add Tea Bag?", false);
  const lemonSqueeze = askBoolean("add lemonsqueeze?", false);
  console.log(cups, sugar, teaBag, lemonSqueeze);
  const result = makeTea({ cups, sugar, teaBag, lemonSqueeze });
  console.log("\n" + result + "\n");
}

function friedRiceService() {
  console.log("\n— Fried Chicken Menu —");
  const servings = askNumber("How many servings", 1);
  const spicy = askNumber("spicy level (0-5)", 1);
  const egg = askBoolean("with egg?", false);
  const chicken = askBoolean("with chicken?", false);
  console.log(servings, spicy, egg, chicken);
  const result = makeFriedRice({servings, spicy, egg, chicken});
  console.log("\n" + result + "\n");
}

function grilledChickenService() {
  console.log("\n— Grilled Chicken Menu —");
  const servings = askNumber("How many servings", 1);
  const sweet = askNumber("sweet level (0-5)", 1);
  const spice = askBoolean("with spice?", false);
  const grilling = askNumber("grilling time?", 1);
  const result = makeGrilledChicken({servings, sweet, spice, grilling});
  console.log("\n" + result + "\n");
}

function serviceLoop() {
  while (true) {
    showMenu();
    const choice = prompt("Choose a menu item (number): ").trim();

    switch (choice) {
      case "1":
        coffeeService();
        break;

      case "2":
        teaService()
        break;

      case "3":
        friedRiceService()
        break;

      case "4":
        grilledChickenService()

      case "0":
        console.log("\nShop closed. Thank you.\n");
        return;

      default:
        console.log("Invalid choice. Please try again.\n");
    }
  }
}

serviceLoop();
```

this a main program for mini caffe

# 3\. Create File Menu

then you can create code in every file about menu

## 3.1 Menu Create Coffe

```javascript
const TOTAL_STIRS = 18;

export default function makeCoffee(options = {}) {
  const { cups = 1, sugar = 1, withMilk = false } = options;
console.log(options)
  // Simple validation
  if (cups <= 0) return "Number of cups must be at least 1.";
  if (sugar < 0) return "Sugar cannot be negative.";

  const steps = [];
  steps.push(`Preparing ${cups} cups of coffee.`);
  steps.push(`Add coffee grounds and ${sugar} tsp of sugar per cup.`);
  steps.push("Pour hot water.");
  if (withMilk) {
    steps.push("Add milk to taste.");
  }

  // Stirring simulation: show stir #1 to #18
  for (let i = 1; i <= TOTAL_STIRS; i++) {
    steps.push(`Stirring... (${i} of ${TOTAL_STIRS})`);
  }

  steps.push("Coffee is ready to be served.");
  return steps.join("\n");
} 
```

## 3.2 Menu Create Tea

```javascript
const TOTAL_STIRS = 18;

export default function makeTea(options = {}) {
    console.log(options)
  const { cups = 1, sugar = 1, teaBag = false , lemonSqueeze = false } = options;

  // Simple validation
  if (cups <= 0) return "Number of cups must be at least 1.";
  if (sugar < 0) return "Sugar cannot be negative.";

  const steps = [];
  steps.push(`Preparing ${cups} cups of tea.`);
  steps.push(`Add tea grounds and ${sugar} tsp of sugar per cup.`);
  steps.push("Pour hot water.");
  if (lemonSqueeze){
      steps.push("add lemon to teste.");
    }
    if (teaBag) {
      steps.push("Add tea bag.");
    }

  steps.push("tea is ready to be served.");
  return steps.join("\n");
}
```

## 3.3 Menu Create Fried Rice

```javascript
const TOTAL_FRYING = 12;

export default function makeFriedRice(options = {}) {
  const { servings = 1, spicy = 1, egg = false , chicken = false} = options;
console.log(options)
  // Simple validation
  if (servings < 0) return "Number of serving must be at least 1.";
  if (spicy < 0) return "spicy cannot be negative.";

  const steps = [];
  steps.push(`Preparing ${servings} servings of friedchiken.`);
  steps.push(`add chili peppers according to taste ${spicy}`);
  steps.push("starting cooking.");
  if (egg) {
    steps.push("Add egg to taste.");
  }
  if (chicken) {
    steps.push("Add chicken to taste.");
  }

  // Stirring simulation: show stir #1 to #18
  for (let i = 1; i <= TOTAL_FRYING; i++) {
    steps.push(`frying... (${i} of ${TOTAL_FRYING})`);
  }

  steps.push("fried rice is ready to be served.");
  return steps.join("\n");
}
```

## 3.4 Menu Create Grilled Chicken

```javascript

export default function makeGrilledChicken(options = {}) {
  const { servings = 1, sweet = 1, spice = false , grilling = 1} = options;
console.log(options)
  // Simple validation
  if (servings < 0) return "Number of serving must be at least 1.";
  if (sweet < 0) return "sweet cannot be negative.";

  const steps = [];
  steps.push(`Preparing ${servings} servings of friedchiken.`);
  steps.push(`add sweet peppers according to taste ${sweet}`);
  steps.push("starting cooking.");
  if (spice) {
    steps.push("Add spice to taste.");
  }

  // Stirring simulation: show stir #1 to #18
  for (let i = 1; i <= grilling; i++) {
    steps.push(`frying... (${i} of ${grilling})`);
  }

  steps.push("grilling chicken is ready to be served.");
  return steps.join("\n");
}
```

# 4\. Running Code

now you can running this project with `node service.js` let’s go to practic

```bash
node service
```

this ui for running this code

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1757487004647/57a4b4e6-9f0b-4dd2-84f3-e4f82a80eef4.png align="center")

you can try make tea with typing `2`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1757487096227/cd13407f-717f-4b93-88e1-cd5a462a9526.png align="center")

you will be asked about the menu you ordered, then process running

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1757487160290/68bd5ae0-1975-4e0b-8d4c-5ad64c272f2b.png align="center")

# 5\. Closing

thanks for you watching and see you next day……..
