dummie-tools
Version:
This is a set of my idea tools
129 lines (124 loc) • 3.02 kB
TypeScript
import * as fs from 'fs';
/**
* Type definitions for dummie-tools
*/
/**
* Options for the printTree function
*/
interface PrintTreeOptions {
/**
* The root directory to print
*/
dirPath: string;
/**
* Maximum depth (0-based) to traverse; Infinity for full depth
*/
maxDepth: number;
/**
* Prefix for formatting each line
*/
prefix?: string;
/**
* Current recursion depth
*/
depth?: number;
/**
* Additional directory names to skip (in addition to defaults)
*/
skipDirs?: Set<string>;
/**
* Whether to interactively prompt for skipping directories
*/
interactive?: boolean;
}
/**
* Entry info with file metadata
*/
interface EntryInfo {
/**
* Entry name
*/
entry: string;
/**
* Full path to the entry
*/
fullPath: string;
/**
* File stats
*/
stats: fs.Stats;
/**
* Whether the entry is a directory
*/
isDirectory: boolean;
}
/**
* Options for the strucview command
*/
interface StrucViewCommandOptions {
/**
* Maximum depth level to display
* Use "la" for all levels or a number
*/
level: string;
/**
* Directory path to scan
*/
dir: string;
/**
* List of directory names to skip
* Can be repeated multiple times
*/
skip: string[];
/**
* Whether to interactively prompt for skipping directories
*/
interactive: boolean;
}
/**
* Base interface for all command options
*/
interface BaseCommandOptions {
/**
* Parent command options, if any
*/
parent?: Record<string, unknown>;
}
/**
* Type guard to check if a value is a string
*
* @param value - The value to check
* @returns True if the value is a string, false otherwise
*/
declare function isString(value: unknown): value is string;
/**
* Type guard to check if a value is a number
*
* @param value - The value to check
* @returns True if the value is a number, false otherwise
*/
declare function isNumber(value: unknown): value is number;
/**
* Type guard to check if a value is an object
*
* @param value - The value to check
* @returns True if the value is an object, false otherwise
*/
declare function isObject(value: unknown): value is Record<string, unknown>;
/**
* Options for the translate command
*/
interface TranslateCommandOptions {
from: string;
to: string;
}
/**
* Main function to print directory tree with interactive skipping
*/
declare function printTree({ dirPath, maxDepth, skipDirs, interactive, }: PrintTreeOptions): Promise<void>;
/**
* Translate text from source to target language.
* Tries HTTP API first, then Puppeteer fallback.
*/
declare function translateText(text: string, from?: string, to?: string): Promise<string>;
export { type BaseCommandOptions, type EntryInfo, type PrintTreeOptions, type StrucViewCommandOptions, type TranslateCommandOptions, isNumber, isObject, isString, printTree, translateText };