Giter Club home page Giter Club logo

favorite_things_cli's Introduction

Favorite Things command line tool

a Node.js cli tool to store any reasonable key-value pairs

Setup and install

Node is required. Check to see if you have node by running the following

$ node -v
v18.9.1 // πŸ‘ˆ any version here means you have it

If you do not have node, the recommended way to install it is with the following

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Download ZIP and unzip file, or clone repo from terminal. If you already have the folder locally, you may skip this step.

$ git clone https://github.com/taylulz/favorite_things_cli.git

From your terminal, navigate into to folder: $ cd favorite_things_cli

Run npm i to setup tests

Run tests with npm test. There should be 9 passing tests.

Running the program

Install the tool by running

$ npm install --location=global

Run the program by typing the following into the terminal...

$ key-value

...and you will be met with the following command prompt

>

Possible commands

Put command

The put command can receive exactly two arguments, a key and a value separated by one space. Input more or less and expect to see Invalid syntax. in the terminal. If run sucessfully and stored in state, expect to see ok. If given an existing key, the put command will update that key's value.

> put favorite_color  // πŸ‘ˆ only one argument
Invalid syntax.
> put favorite_color purple
ok
> put favorite_emoji πŸ˜‹
ok

Fetch command

The fetch command can receive exactly one argumentβ€” a key. Input more or less and expect to see Invalid syntax.. If a value for that key exists, the value will be printed to the terminal. If a value for that key does not exist, expect to see Value not found. in the terminal.

> fetch favorite_color purple  // πŸ‘ˆ more than one argument
Invalid syntax.
> fetch favorite_emoji
πŸ˜‹
>fetch favorite_animal
Value not found.

Exit command

The exit command closes the session. You may also use ctrl+c. The session's state will be erased.

> exit
Bye!

Unknown commands

If any unknown commands are received, expect to see the following string

Unknown command. Known commands are: put, fetch, exit

Uninstall tool

If you wish to uninstall the tool, run the following. Then delete the folder favorite_things_cli

$ npm uninstall --location=global favorite_things_cli

Tools used

This tool was designed to meet specific requirements. Click below to view the requirements.
Create a command line tool for storing and fetching key-value string pairs.

The tool must be able to be run from the command line by typing "key-value".

Running the tool must open an interactive session that accepts put, fetch, and exit commands. When ready to accept a command, it must output the string "> " as a command prompt.

put command should accept a key and a value, for example, "put favorite_color purple". If the key already exists, the old value should be replaced. If successful, the command should output the string "ok".

fetch command should just accept a key, for example, fetch favorite_color. If a value with that key has been entered, it should output that value ("purple"). If no value has been entered for that key, it should output the string "Value not found."

The exit command should output the string "Bye!" and exit the program.

If any other command is entered, it should output the string "Unknown command. Known commands are: put, fetch, exit".

If a command has the wrong number of arguments or is otherwise malformed, it should output the string "Invalid syntax."

your program should accept any reasonable strings as names and values.

$ key-value
> put favorite_color purple
ok
> put favorite_flavor strawberry
ok
> fetch favorite_color
purple

> fetch favorite_animal
value not found
> exit
Bye!

favorite_things_cli's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.