Skip to content

[cli] Disable progress bar when running in non-interactive mode #3913

@oowekyala

Description

@oowekyala

Followup on #3866

TLDR:

  • the PMD CLI should automatically disable the progress bar when we can detect that the output is piped.
  • this can be done unreliably in Java, and more reliably in shell (although we also have to find a solution for the windows shell)
  • if PMD silently adds --no-progress when it detects a non-interactive shell session, we need to have a --progress switch that explicitly enables the progress bar even in that case.

Original thread:

should we try to be smart and have this off by default when the terminal is not interactive (ie: output is being redirected to a file)?

In Java this can be done checking if System.console() is null, but this is a proxy, as it fails if either the STDOUT or STDIN are not connected to a device… checking solely for STDOUT would require an equivalent to C's isatty, which is unfortunately not available without JNI.

Originally posted by @jsotuyod in #3866 (comment)

Should this maybe be done inside the shell wrapper instead? stackoverflow.com/questions/911168/how-can-i-detect-if-my-shell-script-is-running-through-a-pipe

Metadata

Metadata

Assignees

No one assigned

    Labels

    in:cliAffects the PMD Command Line Interface

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions