main_mac.mm 1.1 KB
Newer Older
1 2 3 4 5
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import <Cocoa/Cocoa.h>
6

7
#include <iostream>
8

9 10
#include "flutter/fml/message_loop.h"
#include "flutter/shell/common/shell.h"
11
#include "flutter/shell/common/switches.h"
12
#include "flutter/shell/platform/darwin/desktop/flutter_application_delegate.h"
13 14
#include "lib/fxl/command_line.h"
#include "lib/fxl/logging.h"
15

16
int main(int argc, const char* argv[]) {
17 18 19 20 21 22
  std::vector<std::string> args_vector;

  for (NSString* arg in [NSProcessInfo processInfo].arguments) {
    args_vector.emplace_back(arg.UTF8String);
  }

23
  auto command_line = fxl::CommandLineFromIterators(args_vector.begin(), args_vector.end());
24 25 26

  // Print help.
  if (command_line.HasOption(shell::FlagForSwitch(shell::Switch::Help))) {
27
    shell::PrintUsage([NSProcessInfo processInfo].processName.UTF8String);
28 29 30
    return EXIT_SUCCESS;
  }

31 32 33
  [NSApplication sharedApplication].delegate =
      [[[FlutterApplicationDelegate alloc] init] autorelease];
  return NSApplicationMain(argc, argv);
34
}