2014-08-10 15:51:44 -06:00
|
|
|
###
|
2014-08-17 08:01:53 -06:00
|
|
|
Requires https://github.com/andialbrecht/sqlparse
|
2014-08-10 15:51:44 -06:00
|
|
|
###
|
2014-08-17 08:01:53 -06:00
|
|
|
getCmd = (inputPath, outputPath, options) ->
|
|
|
|
path = options.sqlformat_path
|
2014-12-27 23:21:06 -07:00
|
|
|
|
|
|
|
optionsStr = "--reindent"
|
|
|
|
if options.indent_size?
|
|
|
|
optionsStr += " --indent_width=#{options.indent_size}"
|
|
|
|
if options.keywords?
|
|
|
|
optionsStr += " --keywords=#{options.keywords}"
|
|
|
|
if options.identifiers
|
|
|
|
optionsStr += " --identifiers=#{options.identifiers}"
|
|
|
|
|
2014-08-17 08:01:53 -06:00
|
|
|
if path
|
|
|
|
# Use absolute path
|
|
|
|
"python \"" + path + "\" \"" + inputPath + "\" " + optionsStr
|
|
|
|
else
|
|
|
|
# Use command available in $PATH
|
|
|
|
"sqlformat \"" + inputPath + "\" " + optionsStr
|
2014-08-10 15:51:44 -06:00
|
|
|
|
2014-08-17 08:01:53 -06:00
|
|
|
"use strict"
|
|
|
|
cliBeautify = require("./cli-beautify")
|
|
|
|
isStdout = true
|
|
|
|
module.exports = cliBeautify(getCmd, isStdout)
|