This project provides a simple command-line interface (CLI) for managing contacts stored in a JSON file. It allows users to list contacts, add new contacts, retrieve a specific contact by ID, and remove contacts.
- List all contacts
- Add a new contact
- Retrieve a contact by ID
- Remove a contact by ID
- Clone the repository:
git clone https://github.com/valik3201/contacts-node-project.git
- Navigate into the project directory:
cd contacts-node-project
- Install dependencies:
npm install
The CLI supports the following actions:
- List Contacts: View all contacts.
node index.js --action list
- Add Contact: Add a new contact. Specify name, email, and phone.
node index.js --action add --name "John Doe" --email "[email protected]" --phone "123-456-7890"
- Get Contact by ID: Retrieve a contact by providing its ID.
node index.js --action get --id "contact_id_here"
- Remove Contact by ID: Remove a contact by providing its ID.
node index.js --action remove --id "contact_id_here"
During development, you can use nodemon to automatically restart the application when changes are detected:
npm run start:dev
This command will start the application with nodemon, enabling hot reloading for faster development.
contacts.js
: Contains functions for managing contacts (list, get by ID, add, remove).index.js
: Entry point for the CLI application.db/contacts.json
: JSON file to store contacts.
fs/promises
: For file system operations with promises.path
: For handling file paths.uuid
: For generating unique IDs for contacts.commander
: For building command-line interfaces.
nodemon
: For automatic restarting of the application during development.
Contributions are welcome! Please feel free to open an issue or submit a pull request.