lib/spoom/cli/helper.rb in spoom-1.2.4 vs lib/spoom/cli/helper.rb in spoom-1.3.0

- old
+ new

@@ -44,9 +44,29 @@ $stderr.print(buffer.string) $stderr.flush end + # Print `message` on `$stderr` + # + # The message is prefixed by a status (default: `Warning`). + sig do + params( + message: String, + status: T.nilable(String), + nl: T::Boolean, + ).void + end + def say_warning(message, status: "Warning", nl: true) + buffer = StringIO.new + buffer << "#{yellow(status)}: " if status + buffer << highlight(message) + buffer << "\n" if nl && !message.end_with?("\n") + + $stderr.print(buffer.string) + $stderr.flush + end + # Returns the context at `--path` (by default the current working directory) sig { returns(Context) } def context @context ||= T.let(Context.new(exec_path), T.nilable(Context)) end