alacritty-theme-switch
Version:
CLI utility for switching Alacritty color themes
70 lines • 3.62 kB
TypeScript
import { ResultAsync } from "neverthrow";
import type { Config } from "../types.js";
import { DirectoryIsFileError } from "../utils/fs-errors.js";
import { type FilePath } from "../utils/fs-utils.js";
import { NoThemesFoundError, ThemeNotFoundError, ThemeNotTOMLError } from "./errors.js";
import { Theme } from "./theme.js";
/**
* Theme manager encapsulates all operations related to theme management.
* @internal Use `createThemeManager` to create an instance.
*/
declare class ThemeManager {
#private;
constructor(config: Config, themes: Theme[], backupPath: FilePath, configPath: FilePath);
/**
* Configuration getter
* @returns The current parsed Alacritty configuration
*/
getConfig(): Config;
/**
* Lists themes.
* @returns A list of all available themes
*/
listThemes(): Theme[];
/**
* Returns the first active theme.
*/
getFirstActiveTheme(): Theme | undefined;
/**
* Applies the selected theme to the Alacritty configuration.
* @param selectedTheme - Theme to apply
* @returns A ResultAsync containing the applied theme or an error
*/
applyTheme(selectedTheme: Theme): ResultAsync<Theme, import("../utils/fs-errors.js").WriteError | import("../utils/toml-errors.js").TomlStringifyError | import("./errors.js").BackupError>;
/**
* Applies the theme with the given filename.
* @param name - Filename of the theme to apply
* @returns A ResultAsync containing the applied theme or an error
*/
applyThemeByFilename(name: string): ResultAsync<never, ThemeNotTOMLError> | ResultAsync<Theme, ThemeNotFoundError>;
/**
* Loads all themes from the given directory.
* If the directory doesn't exist, it will be created.
* If the directory exists but is a file, an error will be returned.
* If the directory exists and contains TOML files, they will be parsed and returned.
* If the directory exists and contains no TOML files, an error will be returned.
*
* @param themeDirPath - Path to the directory containing custom themes' files
* @returns A ResultAsync containing an array of all themes or an error
*/
static loadThemes(themeDirPath: FilePath): ResultAsync<Theme[], import("../utils/fs-errors.js").FileNotFoundError | import("../utils/fs-errors.js").FileNotReadableError | DirectoryIsFileError | import("../utils/fs-errors.js").DirectoryNotAccessibleError | import("../utils/toml-errors.js").TomlParseError | NoThemesFoundError>;
}
/**
* Type alias for ThemeManager instance.
*/
export type IThemeManager = InstanceType<typeof ThemeManager>;
/** Theme manager input parameters */
type ThemesManagerParams = {
/** Path to the backup file */
backupPath: FilePath;
/** Path to the Alacritty configuration file */
configPath: FilePath;
/** Path to the directory containing custom themes' files */
themesDirPath: FilePath;
};
/**
* Factory function for creating a theme manager.
*/
export declare function createThemeManager(params: ThemesManagerParams): ResultAsync<ThemeManager, import("../utils/fs-errors.js").FileNotFoundError | import("../utils/fs-errors.js").FileNotReadableError | import("../utils/fs-errors.js").FileNotTOMLError | import("../utils/fs-errors.js").FileIsDirectoryError | DirectoryIsFileError | import("../utils/fs-errors.js").DirectoryNotAccessibleError | import("../utils/fs-errors.js").WriteError | import("../utils/toml-errors.js").TomlParseError | import("../utils/toml-errors.js").TomlStringifyError | NoThemesFoundError>;
export {};
//# sourceMappingURL=theme-manager.d.ts.map