Skip to content

jks8787/foodValuizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foodValuizer

Food waste is a big problem and to keep track of the value lost this CLI tool is here to help.

Logic

  • Eaten food: 100% of cost is translated into value
  • Composted food: 10% of cost is translated into value
  • Recycled food: 5% of cost is translated into value
  • Trashed food: 0% of cost is translated into value

Index

Local Usage

$ git clone git@github.com:jks8787/foodValuizer.git
$ cd foodValuizer/
$ npm install
$ npm link
$ foodValuizer hello
hello world from ./src/commands/hello.js
$ foodValuizer (-v|--version|version)
foodValuizer/0.0.1 darwin-x64 node-v8.12.0
$ foodValuizer --help hello
Outputs hello message

USAGE
  $ foodValuizer hello

OPTIONS
  -n, --name=name  name to print

DESCRIPTION
  ...

Commands

foodValuizer hello

Outputs hello message

USAGE
  $ foodValuizer hello

OPTIONS
  -n, --name=name  name to print

DESCRIPTION
  ...

See code: src/commands/hello.js

foodValuizer goodbye

Outputs goodbye message

USAGE
  $ foodValuizer goodbye

OPTIONS
  -n, --name=name  name to print

DESCRIPTION
  ...

See code: src/commands/goodbye.js

foodValuizer valuize

Valuizes input

USAGE
  $ foodValuizer valuize

OPTIONS
  -i, --input=input  input to be valuized

DESCRIPTION
  ...
  returns the input as well as the following:

  final total value from given input: VALUE_OUT_PUT_HERE
  overall cost from given input: OVERALL_COST_HERE

See code: src/commands/valuize.js

Example Use

# Run the following command:
$ foodValuizer valuize --input='[
  { category: "produce", cost: 1.00, usage: "eaten" },
  { category: "produce", cost: 1.50, usage: "trashed" },
  { category: "dairy", cost: 3.00, usage: "composted" },
  { category: "dairy", cost: 4.00, usage: "recycled" },
  { category: "drinks", cost: 2.00, usage: "recycled" },
  { category: "meat", cost: 5.00, usage: "composted" }
]'

# Expect the following output:
valuizing input: [
  { category: "produce", cost: 1.00, usage: "eaten" },
  { category: "produce", cost: 1.50, usage: "trashed" },
  { category: "dairy", cost: 3.00, usage: "composted" },
  { category: "dairy", cost: 4.00, usage: "recycled" },
  { category: "drinks", cost: 2.00, usage: "recycled" },
  { category: "meat", cost: 5.00, usage: "composted" }
]
final total value from given input: 1.40
overall cost from given input: 16.50

foodValuizer help [COMMAND]

display help for foodValuizer

USAGE
  $ foodValuizer help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

Tests

$ npm test
> foodValuizer@0.0.1 test /Users/janicesmith/code/foodValuizer
> nyc mocha --forbid-only "test/**/*.test.js"



 goodbye
   ✓ runs goodbye (174ms)
   ✓ runs goodbye --name janice

 hello
   ✓ runs hello
   ✓ runs hello --name jeff

 valuize eaten and trashed
   ✓ runs valuize
   ✓ runs valuize --input='[{category: 'produce', cost: 1.00, usage: 'eaten'}, {category: 'produce', cost: 1.00, usage: 'trashed'}]'

 valuize eaten, trashed and recycled
   ✓ runs valuize --input='[{category: 'produce', cost: 1.00, usage: 'eaten'}, {category: 'produce', cost: 1.00, usage: 'trashed'}, {category: 'drinks', cost: 3.00, usage: 'recycled'}]'

 valuize eaten, trashed and composted
   ✓ runs valuize --input='[{category: 'produce', cost: 1.00, usage: 'eaten'}, {category: 'produce', cost: 1.00, usage: 'trashed'}, {category: 'dairy', cost: 3.00, usage: 'composted'}]'

 valuize eaten, trashed and a non-recyclable being recycled
   ✓ runs valuize --input='[{category: 'produce', cost: 1.00, usage: 'eaten'}, {category: 'produce', cost: 1.00, usage: 'trashed'}, {category: 'dairy', cost: 3.00, usage: 'recycled'}]'

 valuize eaten, trashed and a non-compostable being composted
   ✓ runs valuize --input='[{category: 'produce', cost: 1.00, usage: 'eaten'}, {category: 'produce', cost: 1.00, usage: 'trashed'}, {category: 'meat', cost: 3.00, usage: 'composted'}]'


 10 passing (236ms)

------------|----------|----------|----------|----------|-------------------|
File        |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------|----------|----------|----------|----------|-------------------|
All files   |      100 |      100 |      100 |      100 |                   |
goodbye.js  |      100 |      100 |      100 |      100 |                   |
hello.js    |      100 |      100 |      100 |      100 |                   |
valuize.js  |      100 |      100 |      100 |      100 |                   |
------------|----------|----------|----------|----------|-------------------|

> foodValuizer@0.0.1 posttest /Users/janicesmith/code/foodValuizer
> eslint .

Notes

This project set up using oclif.

About

Food waste is a big problem and to keep track of the value lost this tool is here to help ( Node CLI tool )

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published