note
Version:
Create timestamped markdown notes from the command line
97 lines • 2.83 kB
TypeScript
/**
* Argument validation utilities for the note CLI.
*
* @since 0.1.0
*/
import * as Array from "effect/Array";
import * as Schema from "effect/Schema";
/**
* Checks if an argument looks like a filename (has dot, no spaces).
*
* Returns true if the argument contains a dot AND has no spaces.
* This catches cases like "file.md", "test.txt", "config.json".
*
* @example
* import { looksLikeFilename } from "note/Validate"
*
* looksLikeFilename("file.md") // true
* looksLikeFilename("test.txt") // true
* looksLikeFilename("hello world") // false
*
* @since 0.1.0
* @category Validation
*/
export declare const looksLikeFilename: (arg: string) => boolean;
/**
* Checks if an argument looks like a flag (starts with - or --, or contains =).
*
* Returns true if the argument:
* - Starts with "-" (short flag or long flag)
* - Contains "=" (key=value syntax)
*
* @example
* import { looksLikeFlag } from "note/Validate"
*
* looksLikeFlag("--help") // true
* looksLikeFlag("-v") // true
* looksLikeFlag("key=value") // true
* looksLikeFlag("hello") // false
*
* @since 0.1.0
* @category Validation
*/
export declare const looksLikeFlag: (arg: string) => boolean;
/**
* Schema that validates a string is a plain title word.
*
* Rejects strings that look like:
* - Flags (starting with `-` or `--`, or containing `=`)
* - Filenames (containing `.` with no spaces)
*
* @example
* import * as Schema from "effect/Schema"
* import { TitleWord } from "note/Validate"
*
* // Valid title words pass through
* Schema.decodeUnknownSync(TitleWord)("hello") // "hello"
* Schema.decodeUnknownSync(TitleWord)("my-title") // "my-title"
*
* @since 0.1.0
* @category Schema
*/
export declare const TitleWord: Schema.filter<Schema.filter<typeof Schema.String>>;
/**
* Parsed title input containing all derived values.
*
* @since 0.1.0
* @category Models
*/
export interface TitleInput {
/** Original words as provided */
readonly words: Array.NonEmptyReadonlyArray<string>;
/** Joined title with spaces preserved */
readonly title: string;
/** URL-safe slug derived from title */
readonly slug: string;
}
/**
* Schema that transforms a non-empty array of validated title words
* into a TitleInput containing the derived title and slug.
*
* Uses mutable tuple type for compatibility with @effect/cli Args.atLeast(1).
*
* @example
* import * as Schema from "effect/Schema"
* import { TitleInput } from "note/Validate"
*
* const result = Schema.decodeUnknownSync(TitleInput)(["hello", "world"])
* // result: { words: ["hello", "world"], title: "hello world", slug: "hello-world" }
*
* @since 0.1.0
* @category Schema
*/
export declare const TitleInput: Schema.Schema<TitleInput, [
string,
...Array<string>
]>;
//# sourceMappingURL=Validate.d.ts.map