My First CoffeeScript
11/05/15
So, after a bit of complete confusion on how to do anything, I wrote this little bit of code (which will hopefully transform into something more significant soon).
argParser = () ->
argparse = require 'argparse'
parser = new argparse.ArgumentParser(
version: '0.0.1'
addHelp: true
description: 'Initialize post for editing'
)
parser.addArgument(
['title'],
help: 'Title of post to initialize'
)
return parser
parseArgs = (rawArgs) ->
parser = argParser()
return parser.parseArgs()
console.log parseArgs process.argv[2..]
Right now, all it does is print out the parsed arguments object that the argparse parser returns.
The idea is to have an "initPost" script that will generate the files I write blog posts in. I'll just feed in the title of my post, and the resulting filename will be named how I want it to be named. Right now, I copy a template file into filename-esque version of the title I have in mind, and that's how I get the file I edit for blogging purposes.
Eventually, I hope to have most of my site stuff hidden under scripts, so I can more easily transition from static filenames to a smarter database.
If I do it fast enough, I can get everything set up all nice right before I start from scratch! Which actually is pretty perfect, will give me a clean slate to work in and experience doing what I want to do.