Repository: troycomi/reportseff

Issue:
Enhancement default behavior of color
Hi,

I am wondering if it is possible to change the behavior of the option color/no-color.
By default, with more than 20 lines, it will create a pager with the color activated because the default of color is True:
```
 reportseff  --since d=7

ESC[1m     JobIDESC[0m ESC[1m   State   ESC[0m ESC[1m   ElapsedESC[0m ESC[1m TimeEff ESC[0m ESC[1m CPUEff ESC[0m ESC[1m MemEff ESC[0m
  15113138 ESC[32m COMPLETED ESC[0m   00:37:55 ESC[31m  0.0%   ESC[0m ESC[32m 94.6%  ESC[0m ESC[31m  0.1%  ESC[0m
  15116136 ESC[32m COMPLETED ESC[0m   00:37:55 ESC[31m  0.0%   ESC[0m ESC[32m 94.7%  ESC[0m ESC[31m  0.1%  ESC[0m
  15119524 ESC[32m COMPLETED ESC[0m   01:37:30 ESC[31m  0.0%   ESC[0m  67.3%   ESC[31m  0.2%  ESC[0m
[...]
```
I think it will be easier to use reportseff for an user, if it let the default value of color of the function echo_via_pager which is "autodetection".

So the library will detect if it can display the color or not.

In my example, I modify a bit the function main by the following code : 
```
    if entries > 20:
        if args.color :
          click.echo_via_pager(output,args.color)
        elif not args.color:
          click.echo_via_pager(output,args.color)
        else:  
          click.echo_via_pager(output)
    else:
        if args.color :
          click.echo(output, color=args.color)
        else:
          click.echo(output)
```
Where args.color is equal to None (instead of True) if the option is not set.

So with this "solution" : 
 --> `reportseff  --since d=7`   will output in color on my shell without need of pipe.
 --> `reportseff  --since d=7 >output_reportseff`  will write in the file without color.
 --> `reportseff --color  --since d=7`   will output ANSI color codes on my shell, need to pipe with less -R to be readable.
 --> `reportseff --color  --since d=7 >output_reportseff` will write in the file the ANSI color codes need to use the option -r to be readable.
 --> `reportseff --no-color --since d=7`  will output without color on my shell.
 --> `reportseff --no-color  --since d=7 >output_reportseff` will write in the file without the color.

The current behavior : 
 --> `reportseff  --since d=7`  will output ANSI color codes on my shell, need to pipe with less -R to be readable.
 --> `reportseff  --since d=7 >output_reportseff` will write in the file the ANSI color codes, need to use the option -r to be readable.
 --> `reportseff --color  --since d=7`   will output ANSI color codes on my shell, need to pipe with less -R to be readable.
 --> `reportseff --color  --since d=7 >output_reportseff` will write in the file the ANSI color codes, need to use the option -r to be readable.
 --> `reportseff --no-color --since d=7`  will output without color on my shell.
 --> `reportseff --no-color  --since d=7 >output_reportseff` will write in the file without the color.

So it will only change de default behavior, if you don't set the option color/no-color. 

I have seen what you have write here https://github.com/troycomi/reportseff#my-output-is-garbled-with-esc0m-all-over-wheres-the-color, but it seems to me more user friendly with my approach. What do you think about that?

I hope it is understandable, thanks for your tool again ! 

Discussion:

Patch:
diff --git a/README.md b/README.md
index 467c572..cc6c199 100644
--- a/README.md
+++ b/README.md
@@ -122,7 +122,7 @@ split_ubam_24419972     RUNNING        01:26:26    ---      ---
 
 Without arguments, reportseff will try to find slurm output files in the
 current directory. Combine with `watch` to monitor job progress:
-`watch -cn 300 reportseff --modified-sort`
+`watch -cn 300 reportseff --color --modified-sort`
 
 ```txt
                 JobID           State          Elapsed   CPUEff   MemEff
@@ -214,6 +214,10 @@ directory to check for slurm outputs.
 - `--since`: Limit results to those occurring after the specified time.  Accepts
   sacct formats and a comma separated list of key/value pairs.  To get jobs in
   the last hour and a half, can pass `h=1,m=30`.
+-`--until`: Limit results to those occurring before the specified time. Accepts
+  sacct formats and a comma separated list of key/value pairs.
+  Useful in combination with the 'since' option to query a specific range.
+- `--partition`: Limit results to a specific partition.
 - `--node/-n`: Display information for multi-node jobs; requires additional
   sacct fields from jobstats.
 - `--node-and-gpu/-g`: Display information for multi-node jobs and GPU information;
@@ -248,6 +252,23 @@ you get an error that pip isn't found, look for a python/anaconda/conda module.
 in an isolated environment.  This resolves issues of dependency versions and
 allows applications to be run from any environment.
 
+### The output has no color with many jobs!
+
+Click should determine if the output supports color display and react automatically
+in a way you expect.  Check that your terminal is setup to display colors and
+that your pager (probably less) will display color by default.  Some commands,
+e.g. `watch` aren't handled properly even when invoked to support color.  Here
+are some useful settings for your `.bashrc`:
+```
+# have less display colors by default.  Will fix `reportseff` not showing colors
+export LESS="-R"
+# for watch aliases, include the `--color` option
+watch -cn 300 reportseff --color --modified-sort
+#      ^                 ^^^^^^^
+```
+You can always for display of color (or suppress it) with the `--color/--no-color`
+options
+
 ### I get an error about broken pipes when chaining to other commands
 
 Python will report that the consumer of process output has closed the stream
@@ -264,20 +285,6 @@ will likely be absent.  Node-level reporting is only shown for jobs which use
 multiple nodes or GPUs.  If you need a list of where jobs were run, you can add
 `--format +NodeList`.
 
-### My output is garbled with ESC[0m all over, where's the color?
-
-Those are ANSI color codes.  Click will usually strip these if it detects
-the consuming process can't display color codes, but `reportseff` defaults
-to always display them.  If you don't care for color, use the `--no-color`
-option.  For less, you can set
-```
-export LESS="-R"
-```
-in your `.bashrc`, or just type `-R` in an active less process.  Some versions
-of `watch` require the `-c` option to display color, others can't display
-colors properly.  If you search for `ansi color <tool>` you should get some
-solutions.
-
 ## Acknowledgments
 
 The code for calling sacct and parsing the returning information was taken
diff --git a/pyproject.toml b/pyproject.toml
index 58ab7e9..1891ee6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "reportseff"
-version = "2.7.3"
+version = "2.7.4"
 description= "Tablular seff output"
 authors = ["Troy Comi <troycomi@gmail.com>"]
 license = "MIT"
diff --git a/src/reportseff/console.py b/src/reportseff/console.py
index 9087594..4803929 100644
--- a/src/reportseff/console.py
+++ b/src/reportseff/console.py
@@ -21,7 +21,7 @@ from .parameters import ReportseffParameters
 )
 @click.option(
     "--color/--no-color",
-    default=True,
+    default=None,
     help="Force color output. No color will use click defaults",
 )
 @click.option(
diff --git a/src/reportseff/parameters.py b/src/reportseff/parameters.py
index 2c12a9e..1f28ad4 100644
--- a/src/reportseff/parameters.py
+++ b/src/reportseff/parameters.py
@@ -28,7 +28,7 @@ class ReportseffParameters:
     def __init__(
         self,
         jobs: tuple,
-        color: bool = True,
+        color: bool,
         debug: bool = False,
         format_str: str = "",
         modified_sort: bool = False,


Test patch:
diff --git a/tests/test_reportseff.py b/tests/test_reportseff.py
index 1605f8a..8a155ae 100644
--- a/tests/test_reportseff.py
+++ b/tests/test_reportseff.py
@@ -173,10 +173,10 @@ def test_short_output(mocker, mock_inquirer):
     mocker.patch.object(OutputRenderer, "format_jobs", return_value="output")
 
     mock_click = mocker.patch("reportseff.console.click.echo")
-    result = runner.invoke(console.main, "--no-color 23000233".split())
+    result = runner.invoke(console.main, " 23000233".split())
 
     assert result.exit_code == 0
-    mock_click.assert_called_once_with("output", color=False)
+    mock_click.assert_called_once_with("output", color=None)
 
 
 def test_long_output(mocker, mock_inquirer):
@@ -192,10 +192,10 @@ def test_long_output(mocker, mock_inquirer):
     mocker.patch("reportseff.console.len", return_value=21)
     mocker.patch.object(OutputRenderer, "format_jobs", return_value="output")
     mock_click = mocker.patch("reportseff.console.click.echo_via_pager")
-    result = runner.invoke(console.main, "--no-color 23000233".split())
+    result = runner.invoke(console.main, " 23000233".split())
 
     assert result.exit_code == 0
-    mock_click.assert_called_once_with("output", color=False)
+    mock_click.assert_called_once_with("output", color=None)
 
 
 def test_simple_job(mocker, mock_inquirer):