mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
added bin dir from dist
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
var FILE = require("file"),
|
||||
SYSTEM = require("system"),
|
||||
OS = require("os"),
|
||||
ObjectiveJ = require("objective-j");
|
||||
|
||||
var parser = new (require("narwhal/args").Parser)();
|
||||
|
||||
parser.usage("file...");
|
||||
parser.help("Cappuccino plist converter.");
|
||||
|
||||
parser.option("-c", "--convert", "format")
|
||||
.help("rewrite property list files in format")
|
||||
.choices({
|
||||
"280north1" : CFPropertyList.Format280North_v1_0,
|
||||
"xml1": CFPropertyList.FormatXML_v1_0
|
||||
});
|
||||
|
||||
parser.option("-l", "--lint", "lint")
|
||||
.help("check the property list files for syntax errors")
|
||||
.set(true);
|
||||
|
||||
parser.option("-h", "--help")
|
||||
.action(parser.printHelp);
|
||||
|
||||
parser.option("-o", "outPath")
|
||||
.help("specify alternate file path name for result;\n\
|
||||
the -o option is used with -convert, and is only\n\
|
||||
useful with one file argument (last file overwrites);\n\
|
||||
the path '-' means stdout.")
|
||||
.set();
|
||||
|
||||
parser.option("-e", "outExtension")
|
||||
.help("specify alternate extension for converted files")
|
||||
.set();
|
||||
|
||||
parser.option("-s", "silent")
|
||||
.help("be silent on success")
|
||||
.set(true);
|
||||
|
||||
exports.main = function(args)
|
||||
{
|
||||
// HACK: add extra "-" to "-convert", etc, for plutil compatibility
|
||||
var args = args.map(function(arg) { return arg.replace(/^(-[^-].+)$/, "-$1"); });
|
||||
var options = parser.parse(args);
|
||||
|
||||
var ok = false;
|
||||
|
||||
if (typeof options.format !== "undefined" || options.lint)
|
||||
{
|
||||
ok = true;
|
||||
options.args.forEach(function(filePath)
|
||||
{
|
||||
var plistObject = CFPropertyList.propertyListFromString(FILE.read(filePath, { charset:"UTF-8" }));
|
||||
|
||||
if (!plistObject)
|
||||
{
|
||||
SYSTEM.stderr.print("Could not recognize format of plist at " + filePath);
|
||||
ok = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.lint)
|
||||
{
|
||||
if (!options.silent)
|
||||
SYSTEM.stderr.print(filePath + ": OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
var string = CFPropertyList.stringFromPropertyList(plistObject, options.format);
|
||||
|
||||
// outextension?
|
||||
if (options.outPath === "-")
|
||||
SYSTEM.stdout.write(string);
|
||||
else
|
||||
FILE.write(options.outPath || filePath, string, { charset:"UTF-8" });
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
parser.printHelp(options);
|
||||
}
|
||||
|
||||
OS.exit(ok ? 0 : 1);
|
||||
}
|
||||
|
||||
if (require.main == module.id)
|
||||
exports.main(system.args);
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("objective-j").run(system.args);
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env narwhal
|
||||
|
||||
require("objective-j/compiler").main(system.args);
|
||||
Reference in New Issue
Block a user