gpt-4o-2024-05-13· OpenAI
WildChat-4.8M (AI2)
Improve the clarity of the following request. Keep the original details. Don't remove…
- User
Improve the clarity of the following request. Keep the original details. Don't remove any details just organize them properly.
Create a JavaScript CLI application in a single .mjs file with the following functionality: It stores bookmarks in a JSON file where the structure is hierarchical, and visualizes the data in the JSON file with HTML. The JSON file and HTML file is stored in the same directory as this application. If the JSON file doesn't exist, a JSON file is created. If it exists, the JSON file is overwritten. The JSON contains bookmarks hierarchically structure. In other words, bookmarks are categorized into directories. Directories and bookmarks have properties. For directories, the properties are id, title, description, and contents. For bookmarks, the properties are id, title, path, and description. The `contents` property of directories is an array that can contain both bookmarks and subdirectories. The user creates directories and bookmarks from the terminal via the `--add or -a` flag. This flag displays an interactive prompt asking for the following: 1. Asks first which to create, directory or bookmark. 2. If directory is selected, it will ask if its a parent directory or subdirectory. - If its a parent directory, id, title and description are provided. - If its a subdirectory, the id of the parent directory it will be contained in, subdirectory's id, title and description are provided. 3. If the bookmark is selected, it will ask for the id of the directory the bookmark will be contained in, the bookmark's own id, its title, its path, and description. After completing, a prompt follows asking to whether save it or not. The user-added directories and bookmarks are contained in a root directory in the JSON file. This root directory has no title and description properties. It has, of course, the `contents` property, and `id` and `name` property. There are properties of directories, bookmarks, an root directory that can be edited via the `--edit or -e` flag. The flag will display an interactive prompt asking for the following: 1. It asks first for the id of the bookmark, directory, or root directory to be modified. 2. After then, it asks for property of the bookmark, directory, or root directory selected that is gonna be modified. The property inputted is checked if it really exists, before proceeding. 3. If the property exists, a prompt will ask for the new value of the property. After completing, a prompt follows asking to whether save it or not. The properties of directories that can be modified are the id, title, and description. For bookmarks, the properties that can modified are the id, title, path, and description. For the root directory, the properties that can be modified are its id and name. The user can delete directories and bookmarks. It can't delete the root directory as it is the foundation of all the directories and bookmarks, hence it is very essential. To delete a directory or a bookmark, just provide the id of the directory or bookmark. To delete a set of directories and bookmarks, their ids are provided, each separated by comma. The JSON file can be visualized using the `--visualize or -v` flag alone. It visualizes the content of the JSON file on an HTML file. If the HTML file doesn't exist, an HTML file is created. If it exists, the HTML file is overwritten. The same also applies to the JSON file. Once the visualization is completed, The HTML file visually represents the structure of the JSON file. The HTML file should have the following features: - Use a minimal neon theme - Allow directories (the parent directory and subdirectories) to be folded and expanded, with neat effects expanding and folding. The root directory should be always expanded. - Display directory titles titles and the root directory title in hex color code `f0f`, and bookmarks titles in hex color code `0ff` - Include tree edges (in hex color code `0f0`) to connect the root directory, directories, and bookmarks, exactly like this ``` 📁 ℹ️ Root Directory Title ├── 📁 ℹ️ Parent Directory Title │ ├── 🔖 ℹ️ Bookmark title │ └── 🔖 ℹ️ Bookmark title ├── 📁 ℹ️ Parent Directory title │ ├── 📁 ℹ️ Subdirectory title │ │ ├── 🔖 ℹ️ Bookmark title │ │ └── 🔖 ℹ️ Bookmark title │ └── 🔖 ℹ️ Bookmark title └── ℹ️ 🔖 Bookmark title ``` The ℹ️ emoji should be clickable. When clicked, a round square container should appear at the center of the screen. The background should blur once the container appears. It should contain the properties of the directory, bookmark or root directory. Specifically, for a directory, it should contain the id and description property. For a bookmark, it should contain the id, path, and description property. For the root directory, it should contain the id and name property. The round square container should have a scroll bar at the right side of it to enable scrolling through content that extends beyond the visible portion of the container, and the ❌ emoji to close the container. Include a comprehensive help menu accessible via the `-h` or `--help` flag, detailing all available commands and their usage. Additionally, implement robust error handling with clear user feedback. Ensure that any potential error is caught and a meaningful message is provided. Moreover, use the ES module format for the JavaScript code. Additional Requirements: - Although the requirement is to keep everything in a single .mjs file, modularizing related functions (even within the same file) using helper methods can improve readability and maintainability. - Add clear and concise code comments - Choose lightweight and optimized libraries when external dependencies are necessary. - Implement effective logging mechanisms to capture important events, errors, and debugging information. - Use clear and readable formatting for displaying results - Provide users with real-time notifications on what the script is doing. This will make the process more transparent, especially for large directories. - Since file operations can take time, ensure that you’re using async/await to handle them efficiently to avoid blocking the main thread. - Use a library like commander.js or yargs for parsing command-line arguments, as it simplifies handling different flags and commands. - Ensure the generated HTML is mobile-friendly. - Enhance animations with libraries for more polished effects - Assistant