Code Monkey home page Code Monkey logo

toy-robot's Introduction

toy-robot

npm version Build Status Coverage Status Greenkeeper badge

A simple CLI to demonstrate a few concepts:

Setup

Requires

  • Node LTS
  • yarn

Installation

Run yarn at root folder

Usage

Use -h to see codified information. Below are some examples:

./index.js -h

  Usage: index <input> PLACE*4,4,NORTH_MOVE_LEFT_RIGHT_REPORT

  CLI to process multiple instructions in batches, with the ability to resume

  Options:

    -V, --version      output the version number
    -f, --file <path>  Input file of multi-line commands such as:
      PLACE 0,0,NORTH
      MOVE
      LEFT
      RIGHT
      REPORT
        
    -d, --debug        Debug flag to print out helpful messages during runtime.
    -s, --store        Create a checksum of input file and store config there to continue next time. Implied by default. Use -r to override.
    --reset            Ignore stored config and start anew.
    -h, --help         output usage information

./index.js -f tests/1.txt -d

Input file, tests/1.txt
File checksum da39a3ee5e6b4b0d3255bfef95601890afd80709
Processing line by line...
Previous config { x: 0, y: 0, direction: 'NORTH', linesToSkip: 0 }
Saving current config { x: 0, y: 0, direction: 'NORTH', linesToSkip: 0 } to /tmp/toy-robot-da39a3ee5e6b4b0d3255bfef95601890afd80709

./index.js -f tests/3.txt --reset -d

Input file, tests/3.txt
File checksum b6895a8822defbfad7180ab18cd667ab5db02b52
Processing line by line...
Previous config {}
PLACE 6,6,WEST Unable to place. Co-ordinates (6, 6) are invalid. Direction WEST is valid.
PLACE 5,5,WEST1 Unable to place. Co-ordinates (5, 5) are valid. Direction WEST1 is invalid.
PLACE 4,4,NORTH Placed. Currently at 4, 4, NORTH.
MOVE Successful. Currently at 4, 5, NORTH.
LEFT Rotated from NORTH to WEST.
MOVE Successful. Currently at 5, 5, WEST.
MOVE Unable to move, would go out of bounds. Currently at 5, 5, WEST.
MOVE Unable to move, would go out of bounds. Currently at 5, 5, WEST.
REPORT 5 5 WEST
REPORT 5 5 WEST
Saving current config { x: 5, y: 5, direction: 'WEST', linesToSkip: 10 } to /tmp/toy-robot-b6895a8822defbfad7180ab18cd667ab5db02b52

./index.js -f tests/3.txt -d

Input file, tests/3.txt
File checksum b6895a8822defbfad7180ab18cd667ab5db02b52
Processing line by line...
Previous config { x: 5, y: 5, direction: 'WEST', linesToSkip: 10 }
1 / 10 lines skipped.
2 / 10 lines skipped.
3 / 10 lines skipped.
4 / 10 lines skipped.
5 / 10 lines skipped.
6 / 10 lines skipped.
7 / 10 lines skipped.
8 / 10 lines skipped.
9 / 10 lines skipped.
10 / 10 lines skipped.
Saving current config { x: 5, y: 5, direction: 'WEST', linesToSkip: 10 } to /tmp/toy-robot-b6895a8822defbfad7180ab18cd667ab5db02b52

toy-robot's People

Contributors

cheshirecode 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.