DEV Community

Vivian
Vivian

Posted on

OSD600 - My First Command Line Tool

The first assignment in OSD requires us to build a simple Static Site Generator(SSG) using any programming language we hope to. I choose node.js since I want to find out more about this tool.

1. My SSG - Introduction

My Static Site Generator is created with the purpose of converting a .txt file into a .html file without having to author any HTML by hand. During the course, this tool will be updated with more and more features.

2. My SGG - Features

  • Allows user to specify a URL to a CSS stylesheet if they want to.
  • If users’ input is a folder, an index.html file will be generated automatically and linked to other generated HTML files.
  • All generated HTML files will be stored in ./dist folder which is created by default.

3. My SGG - Options

imageNote: -o or --output option hasn't been applied yet.

4. My SGG - Usage

node index.js -i testing.txt 
node index.js -i testing
node index.js -i 'Silver Blaze.txt' -s 'https://cdn.jsdelivr.net/npm/water.css@2/out/water.css'

Enter fullscreen mode Exit fullscreen mode

Note: With file name contains white space, it should be placed inside single('') or double("") quotation mark.

5. My SSG - Example

testing.txt -> command: node index.js -i testing.txt -s https://cdn.jsdelivr.net/npm/water.css@2/out/water.css

This is a sentence!

This is a paragraph: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the 
industry's standard dummy text ever since the 1500s.
Enter fullscreen mode Exit fullscreen mode

Transfered into:

./dist/testing.html

<!doctype html>
<html lang="en" dir="ltr">
<head>
<title>testing</title>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">


</head>
<body>
<p>This is a sentence!</p>

<p>This is a paragraph: Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the 
industry's standard dummy text ever since the 1500s.</p>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

6. Git Hub Repo

https://github.com/hlavu/my-ssg

Finally, thank for spending time reading this post.

Top comments (0)