wordle-word
A simple CLI tool and Node.js module to fetch Wordle solutions for various dates.
Features
- Get Today's Solution: Quickly retrieve the current day's Wordle solution.
- Solutions for the Next Week: See upcoming Wordle answers.
- Custom Date Solutions: Look up the Wordle solution for any specific date.
- Easy to Use: A straightforward command-line interface.
Installation
You can install wordle-word
globally via npm, which makes the wordle
command available in your terminal from any directory.
npm install -g wordle-word
If you plan to use it as a module in another project, install it as a dependency:
npm install wordle-word
Requirements
This package uses the native fetch
API, which is available in Node.js versions > 18 (experimental) and stable in versions later than 21. Please ensure you're running a compatible version of Node.js for the CLI tool to function correctly.
You can check your Node.js version with:
node -v
Usage
As a Command-Line Tool (CLI)
Once installed globally, you can use the wordle
command with various options:
Get Today's Wordle Solution\ Simply run the
wordle
command without any arguments:wordle
This will fetch and display the Wordle solution for your local current date.
Get Wordle Solutions for the Next Week\ To view the solutions for today and the next six days:
wordle --next-week # Or using the shorthand: wordle -n
Get Wordle Solution for a Custom Date\ Specify a date in the
YYYY-MM-DD
format using the--date
(or-d
) option:wordle --date 2023-10-27 # Or using the shorthand: wordle -d 2023-10-27
View Help and Version Information\ To see all available options and examples:
wordle --help # Or using the shorthand: wordle -h
To check the version of your installed
wordle-word
package:wordle --version # Or using the shorthand: wordle -v
As a Module
You can also import and use the getSolution
function directly in your Node.js projects.
First, ensure wordle-word
is installed as a local dependency:
npm install wordle-word
Then, in your project:
import { getSolution } from 'wordle-word';
async function displaySolution() {
try {
// Get today's solution
const todaySolution = await getSolution(new Date());
console.log(`Today's Wordle solution: ${todaySolution.toUpperCase()}`);
// Get solution for a specific date
const customDate = '2023-01-01'; // Example date
const customSolution = await getSolution(customDate);
console.log(`Wordle solution for ${customDate}: ${customSolution.toUpperCase()}`);
// You can also iterate for multiple dates
console.log('\nSolutions for the next 3 days:');
for (let i = 0; i < 3; i++) {
const date = new Date();
date.setDate(date.getDate() + i);
const solution = await getSolution(date);
// Remember to format the date nicely for display if needed
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
console.log(` ${year}-${month}-${day}: ${solution.toUpperCase()}`);
}
} catch (error) {
console.error('Error:', error.message);
}
}
displaySolution();
License
This project is licensed under the ISC License.