Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Suggestion: Output FIGlet as Code Comment. #4

Open
suchislife801 opened this issue Mar 6, 2023 · 1 comment
Open

Feature Suggestion: Output FIGlet as Code Comment. #4

suchislife801 opened this issue Mar 6, 2023 · 1 comment

Comments

@suchislife801
Copy link

suchislife801 commented Mar 6, 2023

Often I find myself code commenting FIGlet outputs and wanted to post a feature suggestion.

Normally, FIGlet is used like this:

import { text } from "https://x.nest.land/deno-figlet@0.0.5/mod.js";

const figletText = await text("getuser", "banner");

Standard output with 2 empty lines at the start and 2 empty lines at the end.


                                                       
  ####   ######  #####  #    #   ####   ######  #####  
 #    #  #         #    #    #  #       #       #    # 
 #       #####     #    #    #   ####   #####   #    # 
 #  ###  #         #    #    #       #  #       #####  
 #    #  #         #    #    #  #    #  #       #   #  
  ####   ######    #     ####    ####   ######  #    # 
                                                       

I propose an alternate comment function for comments, like this:

async function comment(source: string, font: string): Promise<string> {
  const figletText = await text(source, font);
  const transformText = figletText.split("\n").slice(1, -2).map((
    line: string,
  ) => ` * ${line}`);

  const figletComment = `/**\n${transformText.join("\n")}\n */`;

  return figletComment;
}

const figletComment = await comment("getuser", "banner");

console.log(figletComment);

Transformed output with 0 empty lines at the start and 0 empty lines at the end.

/**
 *   ####   ######  #####  #    #   ####   ######  #####  
 *  #    #  #         #    #    #  #       #       #    # 
 *  #       #####     #    #    #   ####   #####   #    # 
 *  #  ###  #         #    #    #       #  #       #####  
 *  #    #  #         #    #    #  #    #  #       #   #  
 *   ####   ######    #     ####    ####   ######  #    # 
 */
@denyncrawford
Copy link
Owner

Hi @suchislife801 sorry for the delayed response. I don't know if this should be part of the core library but I guess is a nice idea to add a formatting module for the outputs. Please make a PR if you feel ok with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants