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: [#653] Update github.com/urfave/cli/v2 to v3 #994

Merged
merged 3 commits into from
Apr 7, 2025
Merged

Conversation

almas1992
Copy link
Contributor

πŸ“‘ Description

Closes goravel/goravel#653

βœ… Checks

  • Added test cases for my code

@Copilot Copilot bot review requested due to automatic review settings April 7, 2025 07:42
@almas1992 almas1992 requested a review from a team as a code owner April 7, 2025 07:42
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

console/cli_context.go:218

  • Verify that r.instance.Int(key) returns an int64 value as expected in urfave/cli v3; if it returns an int, consider applying an explicit conversion to int64 for consistency in OptionInt64.
return r.instance.Int(key)

Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 87.03704% with 14 lines in your changes missing coverage. Please review.

Project coverage is 70.18%. Comparing base (9e85faf) to head (b98c632).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
console/cli_context.go 8.33% 11 Missing ⚠️
support/color/color.go 0.00% 2 Missing ⚠️
console/application.go 96.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #994      +/-   ##
==========================================
+ Coverage   70.04%   70.18%   +0.14%     
==========================================
  Files         168      168              
  Lines       11353    11428      +75     
==========================================
+ Hits         7952     8021      +69     
- Misses       3050     3056       +6     
  Partials      351      351              

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines 186 to +191
case command.FlagTypeIntSlice:
flag := flag.(*command.IntSliceFlag)
var int64Slice []int64
for _, v := range flag.Value {
int64Slice = append(int64Slice, int64(v))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The cli code is weird: IntSliceFlag vs []int64

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it’s definitely weird. In v3, the original int was replaced with int64, so the flag no longer returns an int. I added a conversion in console/application.go to preserve the original behavior.

Copy link
Member

Choose a reason for hiding this comment

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

I think Int* can removed, only keep Int64*.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, case command.FlagTypeInt and case command.FlagTypeInt64 can use the same flow (in our framework, still distinguish FlagTypeInt and FlagTypeInt64). The same with slice.

@almas1992
Copy link
Contributor Author

almas1992 commented Apr 7, 2025

Improved the flag sorting logic based on the feedback in this comment, ensuring consistent output order.

@almas1992
Copy link
Contributor Author

I’ve added a new function:

func handleNoANSI() {
	if noANSI || env.IsNoANSI() {
		color.Disable()
	} else {
		color.Enable()
	}
}

This ensures that the --no-ansi option doesn’t have side effects between commands.
For example, in the following case:

type Test struct {
}

// Signature The name and signature of the console command.
func (r *Test) Signature() string {
	return "app:test"
}

// Description The console command description.
func (r *Test) Description() string {
	return "Command description"
}

// Extend The console command extend.
func (r *Test) Extend() command.Extend {
	return command.Extend{Category: "app"}
}

// Handle Execute the console command.
func (r *Test) Handle(ctx console.Context) error {
	artisan := facades.Artisan()
	_ = artisan.Call("help --no-ansi build")
	ctx.NewLine()
	_ = artisan.Call("help migrate")
	return nil
}

Result:

image image

Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@almas1992 almas1992 merged commit 31b5334 into master Apr 7, 2025
13 checks passed
@almas1992 almas1992 deleted the almas/#653 branch April 7, 2025 14:43
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.

Update github.com/urfave/cli/v2 to v3
3 participants