legal-markdown-js
Version:
Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version
65 lines ⢠2.4 kB
JavaScript
/**
* Archive Options Prompt
*
* This module handles user interaction for configuring source file archiving
* in the interactive CLI. It provides prompts for enabling archiving and
* customizing the archive directory.
*
* @module
*/
import { confirm, input } from '@inquirer/prompts';
import { RESOLVED_PATHS } from '../../../constants/index.js';
import { ArchiveManager } from '../../../utils/archive-manager.js';
import chalk from 'chalk';
/**
* Prompt user for archive configuration options
*
* @returns Promise resolving to the archive configuration
*/
export async function promptArchiveOptions() {
console.log(chalk.bold.cyan('\nš Source File Management'));
console.log('Configure what happens to your source files after processing.\n');
// Ask if user wants to enable archiving
const enableArchiving = await confirm({
message: 'Archive source file after successful processing?',
default: false,
});
if (!enableArchiving) {
return { enableArchiving: false };
}
// Show default directory
console.log(chalk.gray(`Default archive directory: ${RESOLVED_PATHS.ARCHIVE_DIR}`));
// Ask if user wants to customize the directory
const useCustomDirectory = await confirm({
message: 'Use a custom archive directory?',
default: false,
});
let archiveDirectory;
if (useCustomDirectory) {
let validDirectory = false;
// Show where the custom directory will be created
console.log(chalk.gray(`Custom directory will be created relative to: ${process.cwd()}`));
while (!validDirectory) {
const customDir = await input({
message: 'Enter custom archive directory:',
default: 'processed',
validate: (input) => {
if (!input.trim()) {
return 'Archive directory cannot be empty';
}
if (!ArchiveManager.isValidArchiveDirectory(input.trim())) {
return 'Invalid directory path or cannot create directory';
}
return true;
},
});
archiveDirectory = customDir.trim();
validDirectory = true;
}
}
return {
enableArchiving,
archiveDirectory,
};
}
//# sourceMappingURL=archive-options.js.map