From 61f9988e7972a2442f07a3f9ac7b8ae9072b8190 Mon Sep 17 00:00:00 2001 From: Ryan Haskell-Glatz Date: Thu, 31 Oct 2019 15:32:08 -0500 Subject: [PATCH] new cli works --- cli/README.md | 12 ++++++++++++ cli/index.js | 10 +++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cli/README.md b/cli/README.md index 1b00983..f75a734 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,6 +1,18 @@ # the cli tool > you _could_ type everything out... or... +``` +usage: elm-spa [options] + +commands: + help prints this help screen + build [options] generates pages and routes + init [options] scaffolds a new project at + +options: + --ui= what your \`view\` returns (default: Html) +``` + ## so the package makes wiring things up consistent And you know what loves consistency? __Computers!__ diff --git a/cli/index.js b/cli/index.js index 51afb34..305637a 100755 --- a/cli/index.js +++ b/cli/index.js @@ -5,9 +5,9 @@ const utils = { bold: str => '\033[1m' + str + '\033[0m' } -const main = ([ command, ...args = [] ] = []) => { +const main = ([ command, ...args ] = []) => { const commands = { help, init, build } - return (commands[command] || commands.help)(args) + return (commands[command] || commands.help)(args || []) } const help = _ => console.info( @@ -23,7 +23,7 @@ options: `) const init = _ => - console.info(`Hey there, this still needs implementation 😬`) + console.info(`\nHey there! This still needs implementation... 😬\n`) const build = (args = []) => { const fs = require('fs') @@ -33,11 +33,11 @@ const build = (args = []) => { const optionArgs = args.filter(a => a.startsWith('--')) const nonOptionArgs = args.filter(a => a.startsWith('--') === false) - const grabOption = (prefix) => optionArgs.filter(option => option.startsWith(prefix)).split(prefix)[1] + const grabOption = (prefix) => (optionArgs.filter(option => option.startsWith(prefix))[0] || '').split(prefix)[1] const relative = nonOptionArgs.slice(-1)[0] || '.' const options = { - ui: grabOption('--ui=') + ui: grabOption('--ui=') || 'Html' } const exploreFolder = (filepath) => {