summaryrefslogtreecommitdiff
path: root/tools/eos-application-manifest/eos-application-manifest.in
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2013-07-08 16:36:54 -0700
committerPhilip Chimento <philip@endlessm.com>2013-10-18 14:02:26 -0700
commit9d0850b4fb74d21f7e3a5189567ef80fc0239b75 (patch)
treeb0fb93c7861eb8e471d1ddc49b064c6288d96dd1 /tools/eos-application-manifest/eos-application-manifest.in
parent60369d32ec26deba64766b58b4470d7b9c8a629f (diff)
'eos-application-manifest' tool with subcommands
This is the framework for an 'eos-application-manifest' tool with subcommands as in git. Currently the 'help' and 'version' subcommands are implemented. [endlessm/eos-sdk#152]
Diffstat (limited to 'tools/eos-application-manifest/eos-application-manifest.in')
-rw-r--r--tools/eos-application-manifest/eos-application-manifest.in47
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/eos-application-manifest/eos-application-manifest.in b/tools/eos-application-manifest/eos-application-manifest.in
new file mode 100644
index 0000000..7edbcb1
--- /dev/null
+++ b/tools/eos-application-manifest/eos-application-manifest.in
@@ -0,0 +1,47 @@
+#!/usr/bin/gjs
+// Copyright 2013 Endless Mobile, Inc.
+
+const Format = imports.format;
+const System = imports.system;
+
+String.prototype.format = Format.format;
+// monkeypatch System.programInvocationName which is not in this version of GJS
+System.programInvocationName = 'eos-application-manifest';
+
+// Other constants, available from subcommands' code
+const commandSearchPath = "@datadir@/eos-application-manifest/commands";
+const programVersion = "@PACKAGE_VERSION@";
+
+// Import commands from commands/ directory (local first)
+imports.searchPath.unshift(commandSearchPath);
+imports.searchPath.unshift('./commands');
+
+// Must invoke a subcommand
+if (ARGV.length === 0) {
+ // automatically invoke "help" command with no arguments
+ const Help = imports.help;
+ Help.execute([]);
+ // System.exit(1); broken, bugzilla.gnome.org #703826
+ throw new Error();
+}
+
+let command_name = ARGV.shift();
+let command;
+try {
+ command = imports[command_name];
+} catch (e) {
+ if (/No JS module '.*' found in search path/.test(e.message)) {
+ let program_name = System.programInvocationName;
+ printerr("%s: '%s' is not a valid command name. See %s help.".format(
+ program_name, command_name, program_name));
+ // System.exit(1); broken
+ throw new Error();
+ }
+}
+try {
+ command.execute(ARGV);
+} catch (e) {
+ printerr('%s: %s'.format(System.programInvocationName, e.message));
+ // System.exit(1); broken
+ throw e;
+}