DEV Community

Cover image for ascii-themes - Node.js CLI Interface to Generate VSCode Themed ASCII Art
Alex Lakatos 🥑
Alex Lakatos 🥑

Posted on

ascii-themes - Node.js CLI Interface to Generate VSCode Themed ASCII Art

I've built a Node.js CLI interface this weekend to generate themed ASCII art. It supports 287 fonts from Figlet and 18 themes from VS Code.

asciicast

This all started because of a tweet Wassim did, and I tried to replicate that. I've managed to do a passable version using online tools but it was a manual process. So I tried recreating it in Node.js using Figlet, and the Monokai Dimmed theme from VS Code. I should have stopped here, it was good enough.

But I went too deep down the rabbit hole, so I built a customizable CLI with more than 5000 options to generate ASCII art in the terminal. Enjoy! And do comment below with whatever cool thing you end up generating with it.

Usage

npx ascii-themes generate dev.to
Enter fullscreen mode Exit fullscreen mode

npx ascii-themes generate dev.to

  • Optional flags:
    • --font The Figlet Font to use. Defaults to 'Slant Relief'.
    • --themeName The VS Code theme to use. Defaults to 'Monokai Dimmed'.
    • --horizontalLayout The horizontal layout to use for the Figlet Font. Defaults to 'default'.
    • --verticalLayout The vertical layout to use for the Figlet Font. Defaults to 'default'.

Interactive Mode

The CLI has 2 interactive modes:

npx ascii-themes -i
Enter fullscreen mode Exit fullscreen mode

Will allow you to select from the available commands (generate, support, interactive) and input the flags for them via text prompts.

npx ascii-themes -i

npx ascii-themes interactive
Enter fullscreen mode Exit fullscreen mode

Will allow you to input the text and select from a list of the available fonts, themes, and layouts.

npx ascii-themes interactive

Options

To see supported fonts and themes run npx ascii-themes support.

Or you can watch this video tweet I did while building the CLI, it shows you all available fonts in one minute.

Top comments (8)

Collapse
 
ibrahimcesar profile image
Ibrahim Cesar • Edited

I tried your example and I get this error:

Invalid regular expression flags
Collapse
 
lakatos88 profile image
Alex Lakatos 🥑

What command did you run?

Collapse
 
ibrahimcesar profile image
Ibrahim Cesar
npx ascii-themes generate dev.to
Thread Thread
 
lakatos88 profile image
Alex Lakatos 🥑

what's your OS and terminal app? you might have to escape that string.

npx ascii-themes generate 'dev.to'

Thread Thread
 
ibrahimcesar profile image
Ibrahim Cesar

I'm a Mac OS with Oh My Zsh in the iTerm2:

 ibrahim.souza@Pudim  ~  npx ascii-themes generate 'dev.to'
npx: instalou 46 em 4.971s
Invalid regular expression flags
 ✘ ibrahim.souza@Pudim  ~  npx ascii-themes generate "dev.to"
npx: instalou 46 em 2.524s
Invalid regular expression flags
Thread Thread
 
lakatos88 profile image
Alex Lakatos 🥑 • Edited

That is totally weird, the CLI doesn't throw that message, it's from somewhere deeper in the dependencies. I can't reproduce it, can you help me debug it please? Maybe even throw in a PR at github.com/AlexLakatos/ascii-themes

I'm guessing it tries to interpret the . in dev.to as regex. What happens if you try some text without the dot, like npx ascii-themes generate "devto"

Collapse
 
vladimirlojanica profile image
Vladimir Lojanica

Works great.
You've ruined my life!

Collapse
 
lakatos88 profile image
Alex Lakatos 🥑

Oh, I've got an update planned for this weekend, stay tuned :D