Skip to content

shell: fix flag parsing of -h and --help#9435

Merged
helderco merged 1 commit into
dagger:mainfrom
helderco:shell-fix-flag-parsing-help
Jan 23, 2025
Merged

shell: fix flag parsing of -h and --help#9435
helderco merged 1 commit into
dagger:mainfrom
helderco:shell-fix-flag-parsing-help

Conversation

@helderco
Copy link
Copy Markdown
Contributor

@helderco helderco commented Jan 23, 2025

Fixes #9423

Before

⋈ modules/alpine -h
Usage of alpine:
                      --arch string
                                                 --branch string
                                                                            --distro string
                                                                                                       --packages strings
Error: constructor: pflag: help requested

After

⋈ modules/alpine -h
Usage of alpine:
      --arch string
      --branch string
      --distro string
      --packages strings
Error: constructor: unknown shorthand flag: "-h"

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
@helderco helderco requested a review from jedevc January 23, 2025 12:43
@helderco helderco added the kind/bug Something isn't working label Jan 23, 2025
Comment thread cmd/dagger/shell_exec.go
func shellPreprocessArgs(fn *modFunction, args []string) ([]string, error) {
func shellPreprocessArgs(ctx context.Context, fn *modFunction, args []string) ([]string, error) {
flags := pflag.NewFlagSet(fn.CmdName(), pflag.ContinueOnError)
flags.SetOutput(interp.HandlerCtx(ctx).Stderr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉 nice, staggered output begone!

@helderco helderco merged commit d360d7f into dagger:main Jan 23, 2025
@helderco helderco deleted the shell-fix-flag-parsing-help branch January 23, 2025 13:21
vikram-dagger pushed a commit to vikram-dagger/dagger that referenced this pull request Feb 7, 2025
Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-h in dagger shell is formatted incorrectly

2 participants