From 7e8f2101977f6b69b4eae45bef9ae5aad26ccd3a Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Mon, 8 Apr 2024 14:22:06 -0700 Subject: [PATCH] style: more clear progress message (#198) For example if you format a single file, we shouldn't say we're formatting code in all languages. What we're really doing is checking which languages your argv are written in. fixes #197 --- docs/format.md | 3 ++- format/defs.bzl | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/format.md b/docs/format.md index bfd5353b..f620558d 100644 --- a/docs/format.md +++ b/docs/format.md @@ -39,7 +39,7 @@ format_multirun( ## format_multirun
-format_multirun(name, jobs, kwargs)
+format_multirun(name, jobs, print_command, kwargs)
 
Create a multirun binary for the given formatters. @@ -67,6 +67,7 @@ Note that `javascript` is a special case which also formats TypeScript, TSX, JSO | :------------- | :------------- | :------------- | | name | name of the resulting target, typically "format" | none | | jobs | how many language formatters to spawn in parallel, ideally matching how many CPUs are available | 4 | +| print_command | whether to print a progress message before calling the formatter of each language. Note that a line is printed for a formatter even if no files of that language are to be formatted. | False | | kwargs | attributes named for each language, providing Label of a tool that formats it | none | diff --git a/format/defs.bzl b/format/defs.bzl index 6b783767..2fb524ac 100644 --- a/format/defs.bzl +++ b/format/defs.bzl @@ -55,7 +55,7 @@ def _format_attr_factory(target_name, lang, toolname, tool_label, mode): "data": [tool_label], } -def format_multirun(name, jobs = 4, **kwargs): +def format_multirun(name, jobs = 4, print_command = False, **kwargs): """Create a multirun binary for the given formatters. Intended to be used with `bazel run` to update source files in-place. @@ -76,6 +76,8 @@ def format_multirun(name, jobs = 4, **kwargs): Args: name: name of the resulting target, typically "format" jobs: how many language formatters to spawn in parallel, ideally matching how many CPUs are available + print_command: whether to print a progress message before calling the formatter of each language. + Note that a line is printed for a formatter even if no files of that language are to be formatted. **kwargs: attributes named for each language, providing Label of a tool that formats it """ commands = [] @@ -99,6 +101,7 @@ def format_multirun(name, jobs = 4, **kwargs): commands = commands, jobs = jobs, keep_going = True, + print_command = print_command, **common_attrs ) @@ -107,6 +110,7 @@ def format_multirun(name, jobs = 4, **kwargs): commands = [c + ".check" for c in commands], jobs = jobs, keep_going = True, + print_command = print_command, **common_attrs )