mirror of
https://github.com/ryannhg/elm-spa.git
synced 2024-11-22 17:52:33 +03:00
new cli works
This commit is contained in:
parent
7bfef97f80
commit
61f9988e79
@ -1,6 +1,18 @@
|
||||
# the cli tool
|
||||
> you _could_ type everything out... or...
|
||||
|
||||
```
|
||||
usage: elm-spa <command> [options]
|
||||
|
||||
commands:
|
||||
help prints this help screen
|
||||
build [options] <path> generates pages and routes
|
||||
init [options] <path> scaffolds a new project at <path>
|
||||
|
||||
options:
|
||||
--ui=<Html|Element> what your \`view\` returns (default: Html)
|
||||
```
|
||||
|
||||
## so the package makes wiring things up consistent
|
||||
|
||||
And you know what loves consistency? __Computers!__
|
||||
|
10
cli/index.js
10
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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user