Skip to content
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

Feat: Added --disableANSI Flag to CLI to enable/disable ANSI Color Codes #1526

Merged
merged 56 commits into from
Apr 19, 2024

Conversation

Akash-Singh04
Copy link
Contributor

@Akash-Singh04 Akash-Singh04 commented Feb 7, 2024

Related Issue

  • Added --enableANSI CLI Flag to enable/disable colour encoding.

Closes: #1520

Describe the changes you've made

  • Added --enableANSIColor PersistantFlag to CLI to enable/disable ASNI Color Codes
    Example of enabled ANSI Colors in Log files:
    image
  • Added it to testCmd inorder to prevent ASNI Color Codes being rendered in this part of report:
    image

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Please let us know if any test cases are added

NIL

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

NIL

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Screenshots (if any)

Usage:

image

Original Updated
**
image
**
image
**

image

** |
image

|

Below is an attached video of the implementation in action:

bandicam.2024-02-09.03-38-03-218.2.1.mp4

Signed-off-by: Akash <akashsingh2210670@gmail.com>
@Akash-Singh04
Copy link
Contributor Author

@slayerjain Kindly review the PR and let me know if any changes are required.

cmd/test.go Outdated Show resolved Hide resolved
cmd/test.go Outdated Show resolved Hide resolved
pkg/service/test/test.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
@PranshuSrivastava
Copy link
Member

Also fix the merge conflicts please

Signed-off-by: Akash <akashsingh2210670@gmail.com>
Signed-off-by: Akash <akashsingh2210670@gmail.com>
@Akash-Singh04
Copy link
Contributor Author

@PranshuSrivastava Kindly review this PR and have a look at the attached video to better understand the implementation, Thank You!

cmd/root.go Outdated Show resolved Hide resolved
pkg/service/test/test.go Outdated Show resolved Hide resolved
pkg/service/test/test.go Outdated Show resolved Hide resolved
@Akash-Singh04 Akash-Singh04 changed the title Feat: Added --enableColor Flag to CLI to enable/disable ASNI Color Codes Feat: Added --enableColor Flag to CLI to enable/disable ANSIColor Codes Feb 12, 2024
@Akash-Singh04 Akash-Singh04 changed the title Feat: Added --enableColor Flag to CLI to enable/disable ANSIColor Codes Feat: Added --enableColor Flag to CLI to enable/disable ANSI Color Codes Feb 12, 2024
Signed-off-by: Akash <akashsingh2210670@gmail.com>
Signed-off-by: Akash <akashsingh2210670@gmail.com>
@Akash-Singh04 Akash-Singh04 changed the title Feat: Added --enableColor Flag to CLI to enable/disable ANSI Color Codes Feat: Added --enableANSIColor Flag to CLI to enable/disable ANSI Color Codes Feb 12, 2024
pkg/service/test/test.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
pkg/service/test/test.go Outdated Show resolved Hide resolved
pkg/service/test/test.go Outdated Show resolved Hide resolved
utils/utils.go Outdated Show resolved Hide resolved
Akash-Singh04 and others added 4 commits April 9, 2024 17:01
Signed-off-by: Akash Singh <akashsingh2210670@gmail.com>
Signed-off-by: Akash Singh <akashsingh2210670@gmail.com>
Signed-off-by: Akash Singh <akashsingh2210670@gmail.com>
@PranshuSrivastava
Copy link
Member

Ok, the first log can be left colored as we haven't fully read the flags by that time, but the second log is being printed by you right? So why can't you just print it after changing the colors instead of before it?

@Akash-Singh04
Copy link
Contributor Author

@PranshuSrivastava Your requested changes have been made

@@ -219,6 +219,7 @@ func (c *CmdConfigurator) AddFlags(cmd *cobra.Command) error {
case "keploy":
cmd.PersistentFlags().Bool("debug", c.cfg.Debug, "Run in debug mode")
cmd.PersistentFlags().Bool("disableTele", c.cfg.DisableTele, "Run in telemetry mode")
cmd.PersistentFlags().Bool("enableANSIColor", c.cfg.EnableANSIColor, "Enable ANSI color in logs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are working correctly, just change the name of this flag to "enableANSI". Currently the name feels too long to type for a flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored

@Akash-Singh04
Copy link
Contributor Author

@PranshuSrivastava Your requested changes have been made

@Akash-Singh04 Akash-Singh04 changed the title Feat: Added --enableANSIColor Flag to CLI to enable/disable ANSI Color Codes Feat: Added --enableANSI Flag to CLI to enable/disable ANSI Color Codes Apr 15, 2024
@re-Tick
Copy link
Contributor

re-Tick commented Apr 18, 2024

Hey @Akash-Singh04, I think the flag should be disableANSIColor since, the value for the enableANSIColor is true by default. Instead the value can be false and flag can be --disableANSIColor. @PranshuSrivastava would that be ok right?

@PranshuSrivastava
Copy link
Member

@re-Tick Yes thats good. I just want the name to be short

@Akash-Singh04 Akash-Singh04 changed the title Feat: Added --enableANSI Flag to CLI to enable/disable ANSI Color Codes Feat: Added --disableANSI Flag to CLI to enable/disable ANSI Color Codes Apr 18, 2024
Signed-off-by: Akash Singh <akashsingh2210670@gmail.com>
@Akash-Singh04
Copy link
Contributor Author

@re-Tick @PranshuSrivastava Your requested changes have been made

Signed-off-by: Akash Singh <akashsingh2210670@gmail.com>
Copy link
Member

@PranshuSrivastava PranshuSrivastava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@re-Tick re-Tick merged commit 5645ab5 into keploy:main Apr 19, 2024
13 of 14 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 19, 2024
@Akash-Singh04 Akash-Singh04 deleted the colorcodeflag branch April 24, 2024 15:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: option to disable ANSI color codes
5 participants