feat(cli): add support for repeated directus tasks

This commit is contained in:
Cory Dransfeldt 2025-06-08 17:21:05 -07:00
parent 8a12e83b13
commit 1f9e2d856f
No known key found for this signature in database
11 changed files with 601 additions and 5 deletions

View file

@ -0,0 +1,43 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import { initDirectusClient, searchItems, updateItem } from '../directus/client.js';
export const updateReadingProgress = async () => {
const config = await loadConfig();
initDirectusClient(config);
const readingBooks = await searchItems('books', '', { read_status: 'started' });
if (!readingBooks.length) {
console.log('📖 No books currently marked as "started".');
return;
}
const { bookId } = await inquirer.prompt({
type: 'list',
name: 'bookId',
message: '📚 Select a book to update progress:',
choices: readingBooks.map(book => {
const title = book.title || book.name || `Book #${book.id}`;
const progress = book.progress ?? 0;
return {
name: `${title} (${progress}%)`,
value: book.id
};
})
});
const { progress } = await inquirer.prompt({
name: 'progress',
message: '📕 New progress percentage (0100):',
validate: input => {
const num = Number(input);
return !isNaN(num) && num >= 0 && num <= 100 || 'Enter a number from 0 to 100';
}
});
await updateItem('books', bookId, { progress: Number(progress) });
console.log(`✅ Updated book progress to ${progress}%`);
};