Added simple "launch" command to the roster shell.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20017 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -16,6 +16,7 @@ const char kShellUsage[] =
|
|||||||
"activate, a [ <team> ] activates the application specified by <team>\n"
|
"activate, a [ <team> ] activates the application specified by <team>\n"
|
||||||
"exit, e exits the roster shell\n"
|
"exit, e exits the roster shell\n"
|
||||||
"help, h prints this help\n"
|
"help, h prints this help\n"
|
||||||
|
"launch [ <program> ] Executes <program> via BRoster::Launch()\n"
|
||||||
"list, l [ <teams> ] lists the applications specified by <teams>\n"
|
"list, l [ <teams> ] lists the applications specified by <teams>\n"
|
||||||
" or all registered applications\n"
|
" or all registered applications\n"
|
||||||
"list-long, ll [ <teams> ] lists the applications specified by <teams>\n"
|
"list-long, ll [ <teams> ] lists the applications specified by <teams>\n"
|
||||||
@@ -43,6 +44,8 @@ public:
|
|||||||
CmdExit(cmdLine);
|
CmdExit(cmdLine);
|
||||||
else if (command == "help" || command == "h")
|
else if (command == "help" || command == "h")
|
||||||
Usage();
|
Usage();
|
||||||
|
else if (command == "launch")
|
||||||
|
CmdLaunch(cmdLine);
|
||||||
else if (command == "list" || command == "l")
|
else if (command == "list" || command == "l")
|
||||||
CmdList(cmdLine);
|
CmdList(cmdLine);
|
||||||
else if (command == "list-long" || command == "ll")
|
else if (command == "list-long" || command == "ll")
|
||||||
@@ -90,6 +93,37 @@ public:
|
|||||||
fTerminating = true;
|
fTerminating = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CmdLaunch(vector<string> &args)
|
||||||
|
{
|
||||||
|
// check args
|
||||||
|
if (args.size() != 2) {
|
||||||
|
printf("launch: requires exactly one argument\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string program = args[1];
|
||||||
|
|
||||||
|
// get an app ref
|
||||||
|
entry_ref ref;
|
||||||
|
status_t error = get_ref_for_path(program.c_str(), &ref);
|
||||||
|
if (error != B_OK) {
|
||||||
|
printf("launch: Failed to get entry ref for \"%s\": %s\n",
|
||||||
|
program.c_str(), strerror(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// launch the app
|
||||||
|
BRoster roster;
|
||||||
|
team_id teamID;
|
||||||
|
error = roster.Launch(&ref, (const BMessage*)NULL, &teamID);
|
||||||
|
if (error == B_OK) {
|
||||||
|
printf("launched \"%s\", team id: %ld\n", program.c_str(), teamID);
|
||||||
|
} else {
|
||||||
|
printf("launch: Failed to launch \"%s\": %s\n",
|
||||||
|
program.c_str(), strerror(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ParseTeamList(vector<string> &args, BList *teamList)
|
static void ParseTeamList(vector<string> &args, BList *teamList)
|
||||||
{
|
{
|
||||||
for (int32 i = 1; i < (int32)args.size(); i++) {
|
for (int32 i = 1; i < (int32)args.size(); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user