CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-gluegun

A delightful toolkit for building Node-powered command-line interfaces (CLIs) with extensive tooling and plugin architecture.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

string-tools.mddocs/

String Manipulation

Extensive string utilities including case conversion, pluralization, padding, trimming, and text manipulation functions for CLI development.

Capabilities

Case Conversion

Functions for converting strings between different case formats.

/**
 * Convert string to camelCase
 * @param value - Input string
 * @returns camelCase formatted string
 */
camelCase(value: string): string;

/**
 * Convert string to kebab-case
 * @param value - Input string
 * @returns kebab-case formatted string
 */
kebabCase(value: string): string;

/**
 * Convert string to snake_case
 * @param value - Input string
 * @returns snake_case formatted string
 */
snakeCase(value: string): string;

/**
 * Convert string to UPPER CASE
 * @param value - Input string
 * @returns UPPER CASE formatted string
 */
upperCase(value: string): string;

/**
 * Convert string to lower case
 * @param value - Input string
 * @returns lower case formatted string
 */
lowerCase(value: string): string;

/**
 * Convert string to Start Case
 * @param value - Input string
 * @returns Start Case formatted string
 */
startCase(value: string): string;

/**
 * Convert string to PascalCase
 * @param value - Input string
 * @returns PascalCase formatted string
 */
pascalCase(value: string): string;

/**
 * Capitalize first letter only
 * @param value - Input string
 * @returns String with first letter capitalized
 */
upperFirst(value: string): string;

/**
 * Lowercase first letter only
 * @param value - Input string
 * @returns String with first letter lowercased
 */
lowerFirst(value: string): string;

Case Conversion Examples:

import { strings } from "gluegun";

const input = "hello world example";

strings.camelCase(input);     // "helloWorldExample"
strings.kebabCase(input);     // "hello-world-example"
strings.snakeCase(input);     // "hello_world_example"
strings.pascalCase(input);    // "HelloWorldExample"
strings.startCase(input);     // "Hello World Example"
strings.upperCase(input);     // "HELLO WORLD EXAMPLE"
strings.lowerCase(input);     // "hello world example"

const name = "myComponent";
strings.upperFirst(name);     // "MyComponent"
strings.lowerFirst(name);     // "myComponent"

String Validation

Utility functions for validating string content and types.

/**
 * Return string unchanged (identity function)
 * @param value - Input string
 * @returns Same string unchanged
 */
identity(value: string): string;

/**
 * Check if string is blank or empty
 * @param value - String to check
 * @returns True if string is null, undefined, empty, or only whitespace
 */
isBlank(value: string): boolean;

/**
 * Check if value is not a string
 * @param value - Value to check
 * @returns True if value is not a string type
 */
isNotString(value: any): boolean;

Validation Examples:

import { strings } from "gluegun";

// Identity function
const original = "test";
strings.identity(original); // "test"

// Blank checking
strings.isBlank("");        // true
strings.isBlank("   ");     // true
strings.isBlank("hello");   // false
strings.isBlank(null);      // true

// Type checking
strings.isNotString("text"); // false
strings.isNotString(123);    // true
strings.isNotString(null);   // true

Padding and Formatting

Functions for padding strings to specific lengths with custom characters.

/**
 * Pad string to specified length
 * @param string - String to pad
 * @param length - Target length
 * @param chars - Characters to use for padding (default: ' ')
 * @returns Padded string
 */
pad(string: string, length: number, chars?: string): string;

/**
 * Pad string at the beginning
 * @param string - String to pad
 * @param length - Target length
 * @param chars - Characters to use for padding (default: ' ')
 * @returns Left-padded string
 */
padStart(string: string, length: number, chars?: string): string;

/**
 * Pad string at the end
 * @param string - String to pad
 * @param length - Target length
 * @param chars - Characters to use for padding (default: ' ')
 * @returns Right-padded string
 */
padEnd(string: string, length: number, chars?: string): string;

/**
 * Repeat string specified number of times
 * @param string - String to repeat
 * @param times - Number of repetitions
 * @returns Repeated string
 */
repeat(string: string, times: number): string;

Padding Examples:

import { strings } from "gluegun";

// Center padding
strings.pad("hello", 10);        // "  hello   "
strings.pad("hello", 10, "*");   // "**hello***"

// Start padding
strings.padStart("42", 5, "0");  // "00042"
strings.padStart("test", 8);     // "    test"

// End padding
strings.padEnd("Name", 10, ".");  // "Name......"
strings.padEnd("left", 8);        // "left    "

// String repetition
strings.repeat("*", 5);           // "*****"
strings.repeat("abc", 3);         // "abcabcabc"

Trimming

Functions for removing whitespace or custom characters from strings.

/**
 * Remove whitespace or custom characters from both ends
 * @param string - String to trim
 * @param chars - Characters to remove (default: whitespace)
 * @returns Trimmed string
 */
trim(string: string, chars?: string): string;

/**
 * Remove whitespace or custom characters from the beginning
 * @param string - String to trim
 * @param chars - Characters to remove (default: whitespace)
 * @returns Left-trimmed string
 */
trimStart(string: string, chars?: string): string;

/**
 * Remove whitespace or custom characters from the end
 * @param string - String to trim
 * @param chars - Characters to remove (default: whitespace)
 * @returns Right-trimmed string
 */
trimEnd(string: string, chars?: string): string;

Trimming Examples:

import { strings } from "gluegun";

// Basic whitespace trimming
strings.trim("  hello world  ");     // "hello world"
strings.trimStart("  hello world");  // "hello world"
strings.trimEnd("hello world  ");    // "hello world"

// Custom character trimming
strings.trim("---hello---", "-");    // "hello"
strings.trimStart("000123", "0");    // "123"
strings.trimEnd("test!!!", "!");     // "test"

Pluralization

Advanced pluralization system with support for custom rules and edge cases.

/**
 * Pluralize word based on count
 * @param word - Word to pluralize
 * @param count - Count to determine singular/plural (optional)
 * @param inclusive - Include count in result (optional)
 * @returns Pluralized string
 */
pluralize(word: string, count?: number, inclusive?: boolean): string;

/**
 * Get plural form of word
 * @param word - Word to pluralize
 * @returns Plural form
 */
plural(word: string): string;

/**
 * Get singular form of word
 * @param word - Word to singularize
 * @returns Singular form
 */
singular(word: string): string;

/**
 * Check if word is plural
 * @param word - Word to check
 * @returns True if word is plural
 */
isPlural(word: string): boolean;

/**
 * Check if word is singular
 * @param word - Word to check
 * @returns True if word is singular
 */
isSingular(word: string): boolean;

/**
 * Add custom pluralization rule
 * @param rule - Regex pattern or string to match
 * @param replacement - Replacement pattern
 */
addPluralRule(rule: string | RegExp, replacement: string): void;

/**
 * Add custom singularization rule
 * @param rule - Regex pattern or string to match
 * @param replacement - Replacement pattern
 */
addSingularRule(rule: string | RegExp, replacement: string): void;

/**
 * Add irregular pluralization rule
 * @param single - Singular form
 * @param plural - Plural form
 */
addIrregularRule(single: string, plural: string): void;

/**
 * Add uncountable word rule
 * @param word - Word or regex pattern that doesn't pluralize
 */
addUncountableRule(word: string | RegExp): void;

Pluralization Examples:

import { strings } from "gluegun";

// Basic pluralization
strings.plural("cat");        // "cats"
strings.plural("box");        // "boxes"
strings.plural("child");      // "children"

// Singularization
strings.singular("cats");     // "cat"
strings.singular("boxes");    // "box"
strings.singular("children"); // "child"

// Count-based pluralization
strings.pluralize("item", 1);           // "item"
strings.pluralize("item", 2);           // "items"
strings.pluralize("item", 5, true);     // "5 items"
strings.pluralize("item", 1, true);     // "1 item"

// Form checking
strings.isPlural("cats");     // true
strings.isSingular("cat");    // true

// Custom rules
strings.addIrregularRule("person", "people");
strings.addUncountableRule("software");
strings.plural("person");     // "people"
strings.plural("software");   // "software"

Core String Interface

Complete interface defining all string manipulation capabilities.

interface GluegunStrings {
  // Case conversion
  identity(value: string): string;
  camelCase(value: string): string;
  kebabCase(value: string): string;
  snakeCase(value: string): string;
  upperCase(value: string): string;
  lowerCase(value: string): string;
  startCase(value: string): string;
  upperFirst(value: string): string;
  lowerFirst(value: string): string;
  pascalCase(value: string): string;

  // Validation
  isBlank(value: string): boolean;
  isNotString(value: any): boolean;

  // Padding and formatting
  pad(string: string, length: number, chars?: string): string;
  padStart(string: string, length: number, chars?: string): string;
  padEnd(string: string, length: number, chars?: string): string;
  repeat(string: string, times: number): string;

  // Trimming
  trim(string: string, chars?: string): string;
  trimStart(string: string, chars?: string): string;
  trimEnd(string: string, chars?: string): string;

  // Pluralization
  pluralize(word: string, count?: number, inclusive?: boolean): string;
  plural(word: string): string;
  singular(word: string): string;
  isPlural(word: string): boolean;
  isSingular(word: string): boolean;
  addPluralRule(rule: string | RegExp, replacement: string): void;
  addSingularRule(rule: string | RegExp, replacement: string): void;
  addIrregularRule(single: string, plural: string): void;
  addUncountableRule(word: string | RegExp): void;
}

Combined Usage Example:

import { strings } from "gluegun";

// CLI command to generate files
const type = "component";
const name = "user profile";

// Process the name
const fileName = strings.kebabCase(name);        // "user-profile"
const className = strings.pascalCase(name);     // "UserProfile"
const pluralType = strings.plural(type);        // "components"

// Create formatted output
const message = strings.padEnd(`Creating ${type}:`, 20) + className;
const path = `src/${pluralType}/${fileName}.ts`;

console.log(message);  // "Creating component: UserProfile"
console.log(path);     // "src/components/user-profile.ts"

docs

cli-builder.md

command-system.md

filesystem-tools.md

http-tools.md

index.md

package-manager-tools.md

patching-tools.md

print-tools.md

prompt-tools.md

semver-tools.md

string-tools.md

system-tools.md

template-tools.md

tile.json