| 916 | |
| 917 | |
| 918 | int main(int argc, char** argv) |
| 919 | { |
| 920 | Flags flags; |
| 921 | mesos::ContentType contentType = mesos::ContentType::PROTOBUF; |
| 922 | |
| 923 | // Load flags from command line only. |
| 924 | Try<flags::Warnings> load = flags.load(None(), argc, argv); |
| 925 | |
| 926 | // TODO(marco): this should be encapsulated entirely into the |
| 927 | // FlagsBase API - possibly with a 'guard' that prevents FlagsBase |
| 928 | // from calling ::exit(EXIT_FAILURE) after calling usage() (which |
| 929 | // would be the default behavior); see MESOS-2766. |
| 930 | if (flags.help) { |
| 931 | cout << flags.usage() << endl; |
| 932 | return EXIT_SUCCESS; |
| 933 | } |
| 934 | |
| 935 | if (load.isError()) { |
| 936 | cerr << flags.usage(load.error()) << endl; |
| 937 | return EXIT_FAILURE; |
| 938 | } |
| 939 | |
| 940 | mesos::internal::logging::initialize(argv[0], false); |
| 941 | |
| 942 | // Log any flag warnings. |
| 943 | foreach (const flags::Warning& warning, load->warnings) { |
| 944 | LOG(WARNING) << warning.message; |
| 945 | } |
| 946 | |
| 947 | if (flags.task.isSome() && flags.task_group.isSome()) { |
| 948 | EXIT(EXIT_FAILURE) << flags.usage( |
| 949 | "Either task or task group should be set but not both." |
| 950 | " Provide either '--task' OR '--task_group'"); |
| 951 | } else if (flags.task.isNone() && flags.task_group.isNone()) { |
| 952 | if (flags.name.isNone()) { |
| 953 | EXIT(EXIT_FAILURE) << flags.usage("Missing required option --name"); |
| 954 | } |
| 955 | |
| 956 | if (flags.shell && flags.command.isNone()) { |
| 957 | EXIT(EXIT_FAILURE) << flags.usage("Missing required option --command"); |
| 958 | } |
| 959 | } else { |
| 960 | // Either --task or --task_group is set. |
| 961 | if (flags.name.isSome() || |
| 962 | flags.command.isSome() || |
| 963 | flags.environment.isSome() || |
| 964 | flags.appc_image.isSome() || |
| 965 | flags.docker_image.isSome() || |
| 966 | flags.volumes.isSome()) { |
| 967 | EXIT(EXIT_FAILURE) << flags.usage( |
| 968 | "'--name, --command, --env, --appc_image, --docker_image," |
| 969 | " --volumes' can only be set when both '--task'" |
| 970 | " and '--task_group' are not set"); |
| 971 | } |
| 972 | |
| 973 | if (flags.task.isSome() && flags.networks.isSome()) { |
| 974 | EXIT(EXIT_FAILURE) << flags.usage( |
| 975 | "'--networks' can only be set when" |
nothing calls this directly
no test coverage detected