Создание красивых выходов Fastlane / командной строки - PullRequest
0 голосов
/ 21 февраля 2019

Нужна помощь Swift / Fastlane.Как предупредить пользователя, когда команда не вызывается должным образом?

Например, у меня есть команда create, для которой требуется специальный ввод:

func createLane(withOptions options: [String: String]?) {
  guard let options = options, let domain = options["domain"] else {
    fatalError("Must specify a `domain` argument")
  }
}

fastlane create domain:hello успешен, как и ожидалось, но если я запускаю его без аргумента - fastlane create - я получаю огромный поток ненужного текста:

[11:27:28]: ▸ Fatal error: Must specify a `domain` argument: file /Users/kelvinlau/Desktop/Bookeroo/fastlane/Fastfile.swift, line 15
[11:27:28]: ▸ sh: line 1: 16583 Illegal instruction: 4  ./fastlane/FastlaneRunner lane create swiftServerPort 2000 > /dev/null
+-----------+--------+
|    Lane Context    |
+-----------+--------+
| LANE_NAME | create |
+-----------+--------+
[11:27:28]: 765: unexpected token at ''
[11:27:28]: fastlane finished with errors

Looking for related GitHub issues on fastlane/fastlane...

➡️  784/776: unexpected token at 'Bad Request' (Faraday::ParsingError)
    https://github.com/fastlane/fastlane/issues/13666 [closed] 56 ?
    6 weeks ago

➡️  FastlaneSwiftRunner[setGithubRelease]- Fatal error: Unexpectedly found nil while unwrapping an Optional value
    https://github.com/fastlane/fastlane/issues/13852 [closed] 4 ?
    5 weeks ago

➡️  Provisioning Profile Delete Error Token
    https://github.com/fastlane/fastlane/issues/13256 [closed] 5 ?
    02 Nov 2018

and 10 more at: https://github.com/fastlane/fastlane/search?q=765%3A%20unexpected%20token%20at%20%27%27&type=Issues&utf8=✓

?  You can ⌘ + double-click on links to open them directly in your browser.
/Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/json-2.1.0/lib/json/common.rb:156:in `parse': [!] 765: unexpected token at '' (JSON::ParserError)
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/json-2.1.0/lib/json/common.rb:156:in `parse'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/command_parser.rb:12:in `parse'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/socket_server.rb:81:in `parse_and_execute_command'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/socket_server.rb:62:in `block in receive_and_process_commands'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/socket_server.rb:49:in `loop'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/socket_server.rb:49:in `receive_and_process_commands'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/socket_server.rb:158:in `listen'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/server/socket_server.rb:38:in `start'
    from /Users/kelvinlau/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/fastlane-2.116.1/fastlane/lib/fastlane/swift_lane_manager.rb:231:in `block in start_socket_thread'

Является ли fatalError неправильным способом сделатьэто для строки cmd?Я не хочу этот поток бесполезной продукции.

...