Permalink
Browse files

Convert CLI commands to CS

Add WIP logic from other branch-
  • Loading branch information...
davidkaneda committed Nov 23, 2014
1 parent 5cf1c62 commit c5b318e60bf06df0b87f85a30c06ae6176a72a7a
@@ -0,0 +1,31 @@
inquirer = require 'inquirer'
path = require 'path'
fs = require 'fs-extra'
logger = require '../../server/lib/logger'
###
Generate a Buckets project with a skeleton.
@param {string} name - The name of the project.
###
module.exports = (opts) ->
logger.warn 'Not implemented yet :/'
opts.path ?= './'
inquirer.prompt [
type: 'input'
name: 'project_name'
message: 'Name of your project'
default: 'my_buckets'
,
type: 'input'
name: 'directory'
message: 'Directory to generate new Buckets app.'
default: path.resolve './'
], (answers) ->
console.log answers
console.log fs.realpathSync answers.directory
process.exit()
View

This file was deleted.

Oops, something went wrong.
View
@@ -0,0 +1,22 @@
###
Enter a REPL session inside a Buckets CMS context.
###
module.exports = (opts) ->
repl = require '../../node_modules/coffee-script/lib/coffee-script/repl'
console.log "\n" + 'Buckets Command Line'.yellow
console.log 'User, Bucket, Entry, and Route' + ' models have been loaded by default.'.grey
console.log 'Type '.grey + '.help' + ' for a list of available commands.'.grey
nodeRepl = require 'repl'
replServer = repl.start
prompt: '' # ⏚ ➙ ➜ ⎔ ⊔ ⏑ ↬ ☮ ➫ ➪ ➭ ⤻
replServer.on 'exit', -> process.exit()
replServer.context.Bucket = require '../../server/models/bucket'
replServer.context.Entry = require '../../server/models/entry'
replServer.context.User = require '../../server/models/user'
replServer.context.Route = require '../../server/models/route'
View

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,6 @@
module.exports = ->
buckets = require '../../'
server = buckets
buildsPath: "./builds/"
server.on 'bucketsError', ->
process.exit()
View

This file was deleted.

Oops, something went wrong.
View
@@ -1,54 +1,4 @@
#!/usr/bin/env node
var buckets = require('nomnom');
var log = require('./utils/log');
/**
* Define commands.
*/
buckets
.script('buckets');
buckets
.command('generate')
.help('Generate a Buckets skeleton project.')
.option('name', {
position: 1,
required: true,
help: 'The name of your project.'
});
buckets
.command('serve')
.help('Serve the local theme directory.')
.option('port', {
position: 1,
required: false,
help: 'The port to run on. Defaults to 3000.'
});
buckets
.command('repl')
.help('Enter a Buckets REPL environment.');
// Eat the user inputs.
var opts = buckets.nom();
/**
* Delegate commands.
*/
switch (opts[0]) {
case 'generate':
require('./commands/generate')(opts.name);
break;
case 'serve':
require('./commands/serve')(opts.port);
break;
case 'repl':
require('./commands/repl')();
break;
}
require('coffee-script/register');
require('./lib/buckets');
View
@@ -0,0 +1,50 @@
buckets = require 'nomnom'
logger = require '../../server/lib/logger'
###
Define commands.
###
buckets
.script 'buckets'
.help '''
usage help
buckets <command> -h
issues
Please report any issues to:
https://assembly.com/buckets
'''
runCommand = (opts)->
try
require("../commands/#{opts[0]}")(opts)
catch e
console.log e
logger.error 'Could not load that command.', error: e
buckets
.command 'generate'
.help 'Generate a Buckets skeleton project.'
.option 'name',
position: 1
required: true
help: 'The name of your project.'
.callback runCommand
buckets
.command 'serve'
.help 'Serve the local theme directory.'
.option 'port',
position: 1
required: false
help: 'The port to run on. Defaults to 3000.'
.callback runCommand
buckets
.command 'repl'
.help 'Enter a Buckets REPL environment.'
.callback runCommand
# Nom nom
buckets.nom()
View
@@ -81,7 +81,7 @@
"harp": "^0.14.0",
"hbs": "^2.7.0",
"inflection": "^1.3.6",
"lodash": "^2.4.1",
"inquirer": "^0.8.0",
"marked": "^0.3.2",
"moment": "^2.7.0",
"mongoose": "^3.8.15",

0 comments on commit c5b318e

Please sign in to comment.