Index: mojo/shell/desktop/launcher_process.cc |
diff --git a/mojo/shell/desktop/launcher_process.cc b/mojo/shell/desktop/launcher_process.cc |
index 09f7fc57e60411668e04279fb751f8c8246226c2..620f9935b7698f3271b4f5ac0aa1c8f9479e1348 100644 |
--- a/mojo/shell/desktop/launcher_process.cc |
+++ b/mojo/shell/desktop/launcher_process.cc |
@@ -15,6 +15,7 @@ |
#include "base/message_loop/message_loop.h" |
#include "base/synchronization/waitable_event.h" |
#include "base/trace_event/trace_event.h" |
+#include "mojo/shell/command_line_util.h" |
#include "mojo/shell/context.h" |
#include "mojo/shell/switches.h" |
@@ -22,6 +23,29 @@ namespace mojo { |
namespace shell { |
namespace { |
+void Usage() { |
+ std::cerr << "Launch Mojo applications.\n"; |
+ std::cerr |
+ << "Usage: mojo_shell" |
+ << " [--" << switches::kContentHandlers << "=<handlers>]" |
+ << " [--" << switches::kDisableCache << "]" |
+ << " [--" << switches::kEnableMultiprocess << "]" |
+ << " [--" << switches::kOrigin << "=<url-lib-path>]" |
+ << " [--" << switches::kTraceStartup << "]" |
+ << " [--" << switches::kURLMappings << "=from1=to1,from2=to2]" |
+ << " [--" << switches::kPredictableAppFilenames << "]" |
+ << " [--" << switches::kWaitForDebugger << "]" |
+ << " [--" << switches::kTestApp << "]" |
+ << " [<mojo-app>] ...\n\n" |
+ << "A <mojo-app> is a Mojo URL or a Mojo URL and arguments within " |
+ << "quotes.\n" |
+ << "Example: mojo_shell \"mojo:js_standalone test.js\".\n" |
+ << "<url-lib-path> is searched for shared libraries named by mojo URLs.\n" |
+ << "The value of <handlers> is a comma separated list like:\n" |
+ << "text/html,mojo:html_viewer," |
+ << "application/javascript,mojo:js_content_handler\n"; |
+} |
+ |
// Whether we're currently tracing. |
bool g_tracing = false; |
@@ -84,6 +108,12 @@ void StartWindowManager(mojo::shell::Context* context) { |
int LauncherProcessMain(int argc, char** argv) { |
const base::CommandLine& command_line = |
*base::CommandLine::ForCurrentProcess(); |
+ |
+ if (command_line.HasSwitch(switches::kHelp)) { |
+ Usage(); |
+ return 0; |
+ } |
+ |
if (command_line.HasSwitch(switches::kTraceStartup)) { |
g_tracing = true; |
base::trace_event::CategoryFilter category_filter( |
@@ -99,6 +129,7 @@ int LauncherProcessMain(int argc, char** argv) { |
{ |
base::MessageLoop message_loop; |
if (!shell_context.Init()) { |
+ Usage(); |
return 0; |
} |
if (g_tracing) { |
@@ -107,8 +138,22 @@ int LauncherProcessMain(int argc, char** argv) { |
base::TimeDelta::FromSeconds(5)); |
} |
- message_loop.PostTask(FROM_HERE, |
- base::Bind(&StartWindowManager, &shell_context)); |
+ // // The mojo_shell --args-for command-line switch is handled specially |
+ // // because it can appear more than once. The base::CommandLine class |
+ // // collapses multiple occurrences of the same switch. |
+ // for (int i = 1; i < argc; i++) { |
+ // ApplyApplicationArgs(&shell_context, argv[i]); |
+ // } |
+ |
+ if (command_line.HasSwitch(switches::kTestApp)) { |
+ message_loop.PostTask( |
+ FROM_HERE, |
+ base::Bind(&mojo::shell::RunCommandLineApps, &shell_context)); |
+ } else { |
+ message_loop.PostTask( |
+ FROM_HERE, |
+ base::Bind(&StartWindowManager, &shell_context)); |
+ } |
message_loop.Run(); |
// Must be called before |message_loop| is destroyed. |