Skip to content

chore: [#880] Make --no-ansi a global option#881

Merged
almas-x merged 2 commits intomasterfrom
chore
Feb 11, 2025
Merged

chore: [#880] Make --no-ansi a global option#881
almas-x merged 2 commits intomasterfrom
chore

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented Feb 11, 2025

📑 Description

The Artisan usage format is artisan [global options] command [options] [arguments...], so it makes more sense for --no-ansi to be a global option.

freeze

Closes https://github.com/goravel/goravel/issues/?

Summary by CodeRabbit

  • Documentation
    • Enhanced CLI help output now displays a "Global options:" label for clearer usage guidance.
  • New Features
    • Refined command flag handling streamlines behavior for terminal output formatting.

✅ Checks

  • Added test cases for my code

@almas-x almas-x requested a review from a team as a code owner February 11, 2025 11:25
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

Walkthrough

The changes update the CLI application's help output and flag handling. In console/application.go, the application now sets a formatted HelpName and the Register method omits the noANSIFlag when appending flags. In console/cli_helper.go and its corresponding test file, the label in the help template for options has been changed from "Options:" to "Global options:" to enhance clarity in the displayed help output.

Changes

File(s) Change Summary
console/application.go Sets a formatted HelpName in NewApplication and removes noANSIFlag from the command flags in the Register method.
console/cli_helper.go, console/cli_helper_test.go Updates the help template label from "Options:" to "Global options:" in the CLI help output and adjusts the corresponding tests accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant A as Application
    participant R as Command Registrar

    U->>A: Call NewApplication(name, usage, usageText, version, useArtisan)
    A->>A: Set HelpName ("<app name> [global options]")
    U->>A: Call Register(commands)
    A->>R: Append flags (excluding noANSIFlag)
    R-->>A: Registered commands returned
Loading
sequenceDiagram
    participant U as User
    participant C as CLI Helper

    U->>C: Request Help
    C->>C: Format help output using appHelpTemplate ("Global options:" label)
    C-->>U: Display help output
Loading

Possibly related PRs

Suggested reviewers

  • hwbrzzl

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a113be2 and 2924daa.

📒 Files selected for processing (3)
  • console/application.go (2 hunks)
  • console/cli_helper.go (1 hunks)
  • console/cli_helper_test.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • console/cli_helper.go
🔇 Additional comments (4)
console/cli_helper_test.go (1)

30-30: LGTM! Test cases updated to reflect global options.

The test cases have been properly updated to verify the new help output format that shows --no-ansi as a global option.

Also applies to: 109-109

console/application.go (3)

37-37: LGTM! Enhanced help output clarity.

The HelpName setting now explicitly shows that global options are available, improving the user experience.


60-60: LGTM! Proper handling of --no-ansi as global option.

The flag handling changes ensure that --no-ansi is only available as a global option, which is consistent with the PR objectives.

Note: The flag is still properly registered as a global flag in NewApplication (line 41).


37-41: Verify help output consistency across commands.

Let's ensure the help output is consistent across all commands.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check help output for all commands to verify consistent formatting

# Build a list of all commands
commands=$(fd -e go -x grep -l "func.*Signature()" {} \;)

# Extract command signatures
for file in $commands; do
  echo "Checking command in $file"
  rg "func.*Signature.*string.*return.*" -A 1 "$file"
done

# Check help output structure
rg "Usage:|Options:|Global options:" --type go

Length of output: 24025


Help output consistency verified across commands.
The verification script output confirms that the help output is consistent across various command implementations, including the "Usage:", "Options:" and "Global options:" formatting. All expected patterns in help messages are present as per our tests and code in console/application.go (lines 37-41) and across other command files.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.54%. Comparing base (a113be2) to head (2924daa).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #881   +/-   ##
=======================================
  Coverage   67.54%   67.54%           
=======================================
  Files         151      151           
  Lines       10386    10387    +1     
=======================================
+ Hits         7015     7016    +1     
  Misses       3001     3001           
  Partials      370      370           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@almas-x almas-x merged commit b6c3861 into master Feb 11, 2025
14 checks passed
@almas-x almas-x deleted the chore branch February 11, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants