DEV Community

Cover image for Introducing TxtToHTML Command Line Tool: Transform Your Text Files into HTML
Bhavik Mistry
Bhavik Mistry

Posted on

Introducing TxtToHTML Command Line Tool: Transform Your Text Files into HTML

Hello Everyone!

We're thrilled to present you to the TxtToHTML 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 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:
git clone https://github.com/bhavik001/TxtToHTML.git
cd TxtToHTML
Enter fullscreen mode Exit fullscreen mode
  1. Make sure you have Node.js install in you device. Check it using this command:
node -v
Enter fullscreen mode Exit fullscreen mode

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

  1. Run the following command in the terminal to download the dependencies:
npm install
Enter fullscreen mode Exit fullscreen mode
  1. Now to run the code write the following command in the terminal:
npm run start
Enter fullscreen mode Exit fullscreen mode

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:
node src/index.js [options] <input>
Enter fullscreen mode Exit fullscreen mode
  1. The command to display help menu:
node src/index.js -h
node src/index.js --help
Enter fullscreen mode Exit fullscreen mode
  1. The command to display the version of the TxtToHTML CLI Tool:
node src/index.js -v
node src/index.js --version
Enter fullscreen mode Exit fullscreen mode
  1. The command which takes .txt file and convert it to .html file and store it in ./til directory.
node src/index.js document.txt
Enter fullscreen mode Exit fullscreen mode
  1. The command which takes .txt files inside the directory and convert it to .html file and store it in ./til directory.
node src/index.js document
Enter fullscreen mode Exit fullscreen mode
  1. The command which take .txt file, convert it into .html file and store in the custom directory
node src/index.js document.txt -o custom
node src/index.js document.txt --output custom
Enter fullscreen mode Exit fullscreen mode
  1. The command which take .txt file from the document directory, convert it into .html file and store in the custom directory
node src/index.js document.txt -o custom
node src/index.js document.txt --output custom
Enter fullscreen mode Exit fullscreen mode
  1. 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.
node src/index.js -o custom document
node src/index.js --output custom document
Enter fullscreen mode Exit fullscreen mode

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!

Top comments (0)