1.0.2 ⢠Published 5 years ago
@abhishekwl/dict_cli v1.0.2
šØ dict (Stack Finance Task)
Robust CLI based thesaurus to play with. Focused on code structure and file organisation.
Built using commander (CLI operations) and chalk (console coloring). Makes API calls to dictionaryapi.com to fetch definitions, synonyms, antonyms and usage examples of a given word.
š Usage
Usage: dict [options] [command]
Options:
-v, --version Displays the current version of the CLI
-h, --help display help for command
Commands:
def <word> Display definitions of a word
syn <word> Display synonyms of a word
ant <word> Display antonyms of a word
ex <word> Display examples of a word
play Let's play a game
help [command] display help for commandš Directory Structure
.
āāā README.md
āāā index.js
āāā package.json
āāā src
āĀ Ā āāā shared
āĀ Ā āĀ Ā āāā commands.metadata.json
āĀ Ā āĀ Ā āāā constants.js
āĀ Ā āĀ Ā āāā random.words.txt
āĀ Ā āāā thesaurus
āĀ Ā āĀ Ā āāā controller
āĀ Ā āĀ Ā āĀ Ā āāā antonym.controller.js
āĀ Ā āĀ Ā āĀ Ā āāā definition.controller.js
āĀ Ā āĀ Ā āĀ Ā āāā example.controller.js
āĀ Ā āĀ Ā āĀ Ā āāā full-dict.controller.js
āĀ Ā āĀ Ā āĀ Ā āāā play.controller.js
āĀ Ā āĀ Ā āĀ Ā āāā synonym.controller.js
āĀ Ā āĀ Ā āāā enums
āĀ Ā āĀ Ā āĀ Ā āāā command.enum.js
āĀ Ā āĀ Ā āāā helpers
āĀ Ā āĀ Ā āĀ Ā āāā play.helper.js
āĀ Ā āĀ Ā āāā services
āĀ Ā āĀ Ā āāā thesaurus.service.js
āĀ Ā āāā util
āĀ Ā āāā index.js
āāā yarn.lockš Done so far
- Implemented
enumsfor command names. - Separation of concerns,
servicelayer deals with API calls,controllerdeals with CLI interaction,helpersaid controllers with functions specific to the module. shareddirectory contains globally shared resources such as constants and command information.- Utility functions are stored in
utildirectory. - Error management at every stage with
try/catchbeing implemented with various error types at the service level as well as the controller level. - Minimalist
index.jsentrypoint with necessary imports only.
š£ Possible Enhancements
- Fetch API key from environment variables, storing it in code to make testing easier.
- Use jsconfig
pathsto make relative imports easier. - Implements typescript to ensure types.
- Improve CLI interface (
prettify). - Display a friendly
did you meanmessage if a command is not found. - Add autoupdate support to the CLI.
- Add
bash/zshautocomplete.
š Screenshots
- Definition

- Synonym

- Antonym

- Example

- Full Dictionary

- Word of the day

- Game
