# Bunjs ve Typescript ile CLI Uygulamasi gelistirmek

![](https://i.imgur.com/9cvWrrk.png)

Commander.js ve Inquirer.js, CLI uygulamaları geliştirirken kullanılan iki farklı kütüphanedir ve farklı amaçlara hizmet ederler:

* Eğer amacınız komut satırı argümanlarını işlemek ve basit komutlar oluşturmaksa, **Commander.js** daha uygun bir seçim olacaktır.
* Ancak kullanıcıdan interaktif geri bildirim almanız gerekiyorsa, **Inquirer.js** kullanmalısınız.

## **Commander.js:**

Komut satırı argümanlarını işlemek ve CLI uygulamaları için bir arayüz sağlamak için kullanılır. Option parsing, komutların tanımlanması ve yardım sayfalarının otomatik üretimi gibi özelliklere sahiptir.

```bash
bun install commander
# npm install commander
```

```typescript
import { program } from 'commander';

program
  .option('-d, --debug', 'output extra debugging')
  .option('-s, --small', 'small pizza size')
  .option('-p, --pizza-type <type>', 'flavour of pizza');

program.parse(process.argv);

const options = program.opts();
if (options.debug) console.log(options);
console.log('pizza details:');
if (options.small) console.log('- small pizza size');
if (options.pizzaType) console.log(`- ${options.pizzaType}`);

```

## **Inquirer.js**

Kullanıcıdan interaktif kullanıcı girdisi almak için kullanılır. Prompts, checkboxes, input fields gibi birçok farklı kullanıcı girdi tipini destekler. Kullanıcılarla interaktif CLI uygulamaları yapmak için tercih edilir.

```bash
bun install inquirer
# npm install commander
```

```typescript
import inquirer from 'inquirer';

const questions = [
  {
    type: 'confirm',
    name: 'toBeDelivered',
    message: 'Is this for delivery?',
    default: false,
  },
  {
    type: 'input',
    name: 'phone',
    message: "What's your phone number?",
    validate(value) {
      const pass = value.match(
        /^([01]{1})?[\\-\\.\\s]?(\\([0-9]{3}\\))?[\\-\\.\\s]?([0-9]{3})[\\-\\.\\s]?([0-9]{4})$/
      );
      if (pass) {
        return true;
      }
      return 'Please enter a valid phone number';
    },
  }
];

inquirer.prompt(questions).then((answers) => {
  console.log('\\nOrder receipt:');
  console.log(JSON.stringify(answers, null, '  '));
});

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/arsiv/programming/bunjs-ve-typescript-ile-cli-uygulamasi-gelistirmek.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
