Skip to content

Add isStdinTerminal and isStdoutTerminal to NewCLI constructor #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2024

Conversation

catatsuy
Copy link
Owner

@catatsuy catatsuy commented May 6, 2024

This pull request introduces changes to the internal/cli/cli.go, internal/cli/cli_test.go, and main.go files. The primary goal of these changes is to improve the handling of terminal-related functionalities in the command-line interface (CLI) of the application. This is achieved by adding new fields to the CLI struct, modifying the NewCLI function, and updating the related tests.

Here are the key changes in order of importance:

  1. Refactoring of the CLI struct and NewCLI function:

    • Two new fields, isStdinTerminal and isStdoutTerminal, were added to the CLI struct to keep track of whether the standard input and output are terminal interfaces.
    • The NewCLI function was updated to accept two new parameters corresponding to these new fields. This change was reflected in all the places where NewCLI was called [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13].
  2. Improved handling of color output:

    • The color field in the CLI struct was renamed to isColor for consistency.
    • The parseFlags method was updated to use the isStdoutTerminal field when determining whether to color the output.
    • The filterProcess method was updated to use the new isColor field instead of the old color field.
  3. Improved handling of terminal input:

    • The parseFlags and validateInput methods were updated to use the isStdinTerminal field when parsing flags and validating input [1] [2].
  4. Updated tests:

    • All tests in the cli_test.go file were updated to reflect the changes in the NewCLI function and the CLI struct [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11].
    • New tests were added to test the behavior of the CLI when the standard input and output are terminal interfaces.
  5. Removal of unused imports:

    • The golang.org/x/term import was removed from cli.go as it is no longer needed after the refactoring.
    • The strings import was added to cli_test.go for the new tests.

@catatsuy catatsuy merged commit 5723082 into main May 6, 2024
@catatsuy catatsuy deleted the feature_have_is_term_on_cli branch May 6, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant