Introducing TxtToHTML Command Line Tool: Transform Your Text Files into HTML
Tags: cli, opensource, javascript, github
Published: 2023-09-14 17:38:30

Hello Everyone!

We're thrilled to present you to the [TxtToHTML](https://github.com/bhavik001/TxtToHTML.git) Command Line Tool, an effective tool built to quickly convert an entire directories of `.txt` files and individual `.txt` files into `.html` format. This ground-breaking project makes use of `Node.js`, a flexible open-source runtime environment for `JavaScript` code. This is particularly noteworthy since it is our first attempt at creating a command line utility.

## Getting Started: Installation Guide
[TxtToHTML](https://github.com/bhavik001/TxtToHTML.git) makes it simple to start your adventure. Here is how to configure the tool on your computer:


1. To clone this repository use the command given below:

```bash
git clone https://github.com/bhavik001/TxtToHTML.git
cd TxtToHTML
```

2.  Make sure you have `Node.js` install in you device. Check it using this command:

```bash
node -v
```

if not download the `Node.js` locally to your device.

3.  Run the following command in the terminal to download the dependencies:

```bash
npm install
```

4. Now to run the code write the following command in the terminal:

```bash
npm run start
```
## Features

1. **Recursive Search for .txt Files**: When a user inputs a folder, TxtToHTML CLI tool will recursively scan that folder for.txt files and recreate the directory structure in the output directory.

2. **Custom Output Directory**: By using the `--output` or `-o` switch, users can select an alternative output directory. The default output directory is "til" if not otherwise specified. If the directory is empty, TxtToHTML CLI tool creates it.

3. **Version Information**: Running TxtToHTML CLI tool with the `--version` or `-v` flag will print the tool's name and current version.

4. **Help Message**: Running TxtToHTML CLI tool with the `--help` or `-h` flag will display a standard help/usage message, explaining how to use the tool, available command-line flags, and arguments.

5. **Input Flexibility**: A single.txt file or a folder containing.txt files can be specified as input by users of the TxtToHTML CLI tool. The programme processes a.txt file if one is given. It processes all.txt files contained in any specified directory if one is provided.

6. **HTML Output Generation**: For each input file, the TxtToHTML CLI tool creates a single.html file. For instance, using the tool to build a new 'bhavik.html' file from a 'bhavik.txt' file. The HTML5 standard is followed by the files that are created.

## How to use this tool
1. The basic command is:

```bash
node src/index.js [options] <input>
```

2. The command to display help menu:

```bash
node src/index.js -h
node src/index.js --help
```

3. The command to display the version of the TxtToHTML CLI Tool:

```bash
node src/index.js -v
node src/index.js --version
```

4. The command which takes `.txt` file and convert it to `.html` file and store it in `./til` directory.

```bash
node src/index.js document.txt
```

5. The command which takes `.txt` files inside the directory and convert it to `.html` file and store it in `./til` directory.

```bash
node src/index.js document
```

6. The command which take `.txt` file, convert it into `.html` file and store in the `custom` directory

```bash
node src/index.js document.txt -o custom
node src/index.js document.txt --output custom
```

7. The command which take `.txt` file from the `document` directory, convert it into `.html` file and store in the `custom` directory

```bash
node src/index.js document.txt -o custom
node src/index.js document.txt --output custom
```

8. This command will search for all `.txt` files in the `document` directory and its subdirectories, convert them to `.html` file, and recreate the same directory structure in the `custom` directory with the corresponding `.html` files.

```bash
node src/index.js -o custom document
node src/index.js --output custom document
```
## License
TxtToHTML CLI Tool operates under the MIT license, granting you the freedom to use and modify it as needed.

Welcome to a new era of effortless text-to-HTML conversion with TxtToHTML CLI Tool!