mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 13:07:02 +00:00
81 lines
1.9 KiB
Plaintext
Executable File
81 lines
1.9 KiB
Plaintext
Executable File
#!/usr/bin/env narwhal
|
|
|
|
var FILE = require("file");
|
|
|
|
|
|
function printUsage()
|
|
{
|
|
print("this is where you say the usage");
|
|
}
|
|
|
|
exports.main = function(args)
|
|
{
|
|
// TODO: args parser
|
|
args.shift();
|
|
|
|
if (args.length < 1)
|
|
return printUsage();
|
|
|
|
var allFiles = NO,
|
|
format = nil,
|
|
filePaths = [],
|
|
outPath = nil,
|
|
outExtension = nil;
|
|
|
|
index = 0,
|
|
count = args.length;
|
|
|
|
for (; index < count; ++index)
|
|
{
|
|
var argument = args[index];
|
|
|
|
if (argument.charAt(0) === '-' && !allFiles)
|
|
{
|
|
if (filePaths.length > 0)
|
|
return printUsage();
|
|
|
|
else if (argument === "-convert")
|
|
format = args[++index];
|
|
|
|
else if (argument === "-o")
|
|
outPath = args[++index];
|
|
|
|
else if (argument === "-e")
|
|
outExtension = args[++index];
|
|
|
|
else if (argument === "--")
|
|
allFiles = YES;
|
|
|
|
else if (argument === "-help")
|
|
return printUsage();
|
|
}
|
|
else
|
|
filePaths.push(args[index]);
|
|
}
|
|
|
|
index = 0;
|
|
count = filePaths.length;
|
|
|
|
for (; index < count; ++index)
|
|
{
|
|
var filePath = filePaths[index],
|
|
data = new objj_data();
|
|
|
|
data.string = FILE.read(filePaths[index], { charset:"UTF-8" });
|
|
|
|
var plistObject = new CPPropertyListCreateFromData(data);
|
|
|
|
if (format === "280north1")
|
|
data = CPPropertyListCreate280NorthData(plistObject);
|
|
|
|
else if (format === "xml1")
|
|
data = CPPropertyListCreateXMLData(plistObject);
|
|
|
|
// outextension?
|
|
FILE.write(outPath || filePath, data.string, { charset:"UTF-8" });
|
|
}
|
|
}
|
|
|
|
if (require.main == module.id)
|
|
exports.main(system.args);
|