| 36 | |
| 37 | |
| 38 | void usage(const char* argv0) |
| 39 | { |
| 40 | // Get a list of available commands. |
| 41 | const Option<string> PATH = os::getenv("PATH"); |
| 42 | |
| 43 | list<string> commands; |
| 44 | |
| 45 | if (PATH.isSome()) { |
| 46 | foreach (const string& path, strings::split(PATH.get(), ":")) { |
| 47 | Try<list<string>> matches = fs::list(path::join(path, "mesos-*")); |
| 48 | if (matches.isSome()) { |
| 49 | foreach (const string& match, matches.get()) { |
| 50 | Try<bool> access = os::access(match, X_OK); |
| 51 | if (access.isSome() && access.get()) { |
| 52 | string basename = Path(match).basename(); |
| 53 | if (basename != "mesos-slave") { |
| 54 | commands.push_back(basename.substr(6)); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | cerr |
| 63 | << "Usage: " << Path(argv0).basename() << " <command> [OPTIONS]" |
| 64 | << endl |
| 65 | << endl |
| 66 | << "Available commands:" << endl |
| 67 | << " help" << endl; |
| 68 | |
| 69 | foreach (const string& command, commands) { |
| 70 | cerr << " " << command << endl; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | |
| 75 | int main(int argc, char** argv) |