Skip to content

Commit

Permalink
Adds stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jreina committed Jul 23, 2019
1 parent d05bf4c commit 6427284
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode
node_modules
src
.gitignore
.npmignore
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "cube",
"name": "blync-party",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"prestart": "npm run build",
"start": "node ./dist/main.js"
"start": "node ./dist/cli/main.js"
},
"keywords": [],
"author": "",
Expand All @@ -25,5 +25,8 @@
"@types/node-hid": "^0.7.2",
"@types/ramda": "^0.26.16",
"typescript": "^3.5.3"
},
"bin": {
"blync-party": "./dist/cli/main.js"
}
}
9 changes: 9 additions & 0 deletions src/cli/CubeOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IPattern } from "../patterns/IPattern";
import { IPatternEngine } from "../engine/IPatternEngine";

export interface CubeOptions {
pattern: IPattern;
engine: IPatternEngine;
name: string;
description: string;
}
34 changes: 34 additions & 0 deletions src/cli/cubeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { MoodRing, Police, Party } from "../patterns";
import { FunctionPatternProcessor } from "../engine/FunctionPatternProcessor";
import { FixedDelayPatternProcessor } from "../engine/FixedDelayPatternProcessor";
import { CubeOptions } from "./CubeOptions";

export const options: Map<string, CubeOptions> = new Map([
[
"mood",
{
pattern: new MoodRing(),
engine: new FunctionPatternProcessor(),
name: "mood",
description: "Chill mode activated!"
}
],
[
"police",
{
pattern: new Police(),
engine: new FixedDelayPatternProcessor(),
name: "police",
description: "Tha block is hot!"
}
],
[
"party",
{
pattern: new Party(),
engine: new FixedDelayPatternProcessor(),
name: "party",
description: "Let's party boiiiiii!!!1!"
}
]
]);
20 changes: 20 additions & 0 deletions src/cli/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

import { BlyncStatic } from "../lib/BlyncStatic";
import { options } from "./cubeConfig";
import { CubeOptions } from "./CubeOptions";
import { showMenu } from "./showMenu";

const [, , patt] = process.argv;
if (!patt) {
showMenu();
process.exit();
}

if (!options.has(patt)) throw new Error(`Pattern (${patt}) not found!`);
const pattern = options.get(patt) as CubeOptions;

(async function run() {
const blync = BlyncStatic.getDevice(0);
await pattern.engine.process(pattern.pattern, blync);
})();
14 changes: 14 additions & 0 deletions src/cli/showMenu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { options } from "./cubeConfig";
const optionText = [...options.entries()].map(
([key, { description }]) => ` ${key}, ${description}`
).join('\r');

export function showMenu() {
console.log(`
Usage
blync-party mood
Options
${optionText}
`);
}
39 changes: 0 additions & 39 deletions src/main.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
"removeComments": false, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
Expand Down

0 comments on commit 6427284

Please sign in to comment.