# File lib/rhc/commands/app.rb, line 26
    def create(name, cartridge, additional_cartridges)
      options.default \
        :dns => true,
        :git => true

      warnings = []
      header "Creating application '#{name}'"
      paragraph do
        table({"Namespace:" => options.namespace,
               "Cartridge:" => cartridge,
               "Gear Size:" => options.gear_size || "default",
               "Scaling:" => options.scaling ? "yes" : "no",
              }
             ).each { |s| say "  #{s}" }
      end

      raise RHC::DomainNotFoundException.new("No domains found. Please create a domain with 'rhc domain create <namespace>' before creating applications.") if rest_client.domains.empty?

      rest_domain = rest_client.find_domain(options.namespace)

      # check to make sure the right options are set for enabling jenkins
      jenkins_rest_app = check_jenkins(name, rest_domain) if options.enable_jenkins

      # create the main app
      rest_app = create_app(name, cartridge, rest_domain,
                            options.gear_size, options.scaling)

      # create a jenkins app if not available
      # don't error out if there are issues, setup warnings instead
      begin
        jenkins_rest_app = setup_jenkins_app(rest_domain) if options.enable_jenkins and jenkins_rest_app.nil?
      rescue Exception => e
        add_issue("Jenkins failed to install - #{e}",
                  "Installing jenkins and jenkins-client",
                  "rhc app create jenkins",
                  "rhc cartridge add jenkins-client -a #{rest_app.name}")
      end

      # add jenkins-client cart
      begin
        setup_jenkins_client(rest_app) if jenkins_rest_app
      rescue Exception => e
        add_issue("Jenkins client failed to install - #{e}",
                  "Install the jenkins client",
                  "rhc cartridge add jenkins-client -a #{rest_app.name}")
      end

      if options.dns
        unless dns_propagated? rest_app.host
          add_issue("We were unable to lookup your hostname (#{rest_app.host}) in a reasonable amount of time and can not clone your application.",
                    "Clone your git repo",
                    "rhc app git-clone #{rest_app.name}")

          output_issues(rest_app)
          return 0
        end

        if options.git
          begin
            run_git_clone(rest_app)
          rescue RHC::GitException => e
            warn "#{e}"
            unless RHC::Helpers.windows? and windows_nslookup_bug?(rest_app)
              add_issue("We were unable to clone your application's git repo - #{e}",
                        "Clone your git repo",
                        "rhc app git-clone #{rest_app.name}")
            end
          end
        end
      end

      display_app(rest_app,rest_app.cartridges,rest_app.scalable_carts.first)

      if issues?
        output_issues(rest_app)
      else
        results { rest_app.messages.each { |msg| say msg } }
      end

      0
    end