gpt-4o-2024-05-13· openai
from WildChat-4.8M
Improve the clarity of the following request. [code]
- User
Improve the clarity of the following request.
code - Assistant
Improve the clarity of the following request.
Create a JavaScript CLI application in a single .mjs file described below:
JSON file where the files and directories are structured hierarchically. The path to the JSON file can be provided via the `--config or -c setup` argument and can be viewed via the `--config or -c view` argument. Check if the provided path leads to a valid JSON file. If invalid, then return an informative error.
Directory on a physical drive that is the object of the JSON file. The path to this directory can also be provided via the `--config setup` argument. Check if the provided path leads to a valid directory. If invalid, then return an informative error.
File properties: id, name, type, extension, path, description. The type property of any file is always `file`.
Directory properties: id, name, type, description, contents. The contents is an array that can contain both files and directories. The type property of any directory is always `directory`.
Add argument: --add or -a [[filename/directory name]/[file path]] [destination]
- destination is a directory id.
- A file is created by giving its name with extension (ex., hello.txt). Directory is added by specifying its name (ex., Species)
- An existing file can be added by giving its path
- Files added are also created in the directory (the object of the JSON file). Their paths in that directory become the path properties in the JSON file.
- The filename of the file to be added to the JSON file is cut into name and extension. Its name becomes its name property and its extension becomes its extension property in the JSON file.
- Directory name specified is added to the JSON file
- JSON file has a predefined directory named `Root` with an id defined as `root`. The only properties it has are its name, and its id, and its contents, which contains files and directories.
- Multiple files and/or directories can be added by separating each filename, directory name, and/or file path with a comma.
- Examples:
- file1, file2, file3 or irectory1, directory2, directory3 or this/is/path1, this/is/path2, this/is/path3
- file1, directory1, file2, directory2, this/is/path1
- Rules:
- Destination should only be of directory type. If its invalid, then return an informative error.
- file path should be checked if it's valid and if it exists. If its invalid, then return an informative error.
- filename should consist of name and extension. If its invalid return an informative error.
Edit argument: --edit or -e [file id] [new filename]
- This argument modifies the filenames of files from the directory (the object of the JSON file)
- File id is associated to a file object in the JSON file. The path property of that file object is used to locate the file from the directory and replace its filename with the new filename specified in the argument.
- Rules:
- File id should be always of file type. When the id is of directory type, return an informative error.
- File id should exist. If its invalid, return an informative error
- filename should consist of name and extension. If its invalid return an informative error.
Move argument: --move or -m [file id/directory id] [destination]
- The file id and directory id are used to identify the file and directory object in JSON to be moved.
- destination should be a directory id.
- Multiple files and/or directories can be moved into a destination directory by separating each file id and/or directory id with a comma.
- Examples:
- filei1, fileid2, fileid3 or dirID1, dirID2, dirID3
- filei1, dirID1, fileid2, dirID2
- Rules:
- File id and directory id should exist. If its invalid, return an informative error.
- Destination should only be of directory type. If its invalid, then return an informative error.
- Destination id should exist. If its invalid, return an informative error.
Delete argument: --delete or -d [file id/directory id]
- Multiple files or directories can be deleted from the JSON file by separating each file id or directory id with a comma (ex., fileid1, fileid2, fileid3)
- Rules:
- File id and directory id should exist. If its invalid, return an informative error.
Help Menu:
- Include a comprehensive help menu accessible via the `-h` or `--help` flag.
- Detail all available commands and their usage.
Code Format:
- Use the ES module format for the JavaScript code.
To improve clarity, we'll break down the request into clear sections with concise instructions, ensuring each requirement is distinctly specified. Here's the improved version:
JavaScript CLI Application Requirements
Develop a JavaScript CLI application contained in a single .mjs file with the following functionality:
JSON Setup:
--config or -c argument.
--config setup <path_to_JSON>: Set path to JSON.--config view: View current JSON file.Directory Setup:
--config setup <path_to_directory>.File Properties:
idnametype (always file)extensionpathdescriptionDirectory Properties:
idnametype (always directory)descriptioncontents (array containing files and directories)Predefined Directory:
root, containing name and contents.Add:
--add or -a <filenames/directories> <destination>file1.txt,file2.txt or dir1,dir2file1.txt, dir1, /path/to/existing/fileEdit:
--edit or -e <file_id> <new_filename>file. Return error if ID refers to a directory.Move:
--move or -m <file_id/directory_id> <destination>fileid1, fileid2 or dirID1, dirID2Delete:
--delete or -d <file_id/directory_id>-h or --help.This improved request clearly structures all necessary details for developing the CLI application, making each section and requirement easy to understand.