Skip to content

Fix default command used for __completeNoDesc alias#2568

Merged
mikefarah merged 1 commit intomikefarah:masterfrom
teejaded:fix-completeNoDesc
Jan 22, 2026
Merged

Fix default command used for __completeNoDesc alias#2568
mikefarah merged 1 commit intomikefarah:masterfrom
teejaded:fix-completeNoDesc

Conversation

@teejaded
Copy link
Copy Markdown
Contributor

@teejaded teejaded commented Jan 9, 2026

Fixes: #2482

__completeNoDesc is an alias for __complete

https://github.com/spf13/cobra/blob/6dec1ae26659a130bdb4c985768d1853b0e1bc06/completions.go#L234

It is used for Powershell tab-completion

yq completion powershell | grep '__completeNoDesc'
    $RequestComp="$Program __completeNoDesc $Arguments"

before:

yq __completeNoDesc --pretty
Error: unknown flag: --pretty
Usage:
  yq eval [expression] [yaml_file1]... [flags]

Aliases:
  eval, e
...

after:

yq __completeNoDesc --pretty
--prettyPrint
:4
Completion ended with directive: ShellCompDirectiveNoFileComp

@teejaded
Copy link
Copy Markdown
Contributor Author

teejaded commented Jan 9, 2026

Hmm the build failed on gosec

+ curl -sSfL https://raw.githubusercontent.com/securego/gosec/master/install.sh
+ sh -s v2.22.11
securego/gosec info checking GitHub for tag 'v2.22.11'
securego/gosec crit unable to find 'v2.22.11' - use 'latest' or see https://github.com/securego/gosec/releases for details

That version is right here:
https://github.com/securego/gosec/releases/tag/v2.22.11

It works locally. Maybe it just needs a retry?

@mikefarah
Copy link
Copy Markdown
Owner

Yeah not sure why it fails like that sometime :/

@mikefarah mikefarah requested a review from Copilot January 22, 2026 02:38
Copy link
Copy Markdown
Contributor

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.

Pull request overview

This PR fixes the handling of the __completeNoDesc completion command to prevent it from triggering the default eval command logic. The __completeNoDesc command is a Cobra alias for __complete used specifically for PowerShell tab-completion.

Changes:

  • Updated the main function logic to exclude __completeNoDesc from the default command fallback
  • Added comprehensive test coverage to verify the fix works correctly

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
yq.go Added __completeNoDesc to the condition that prevents default command execution for completion commands
yq_test.go Added test cases to verify __completeNoDesc is handled correctly alongside __complete

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread yq_test.go
}

func TestMainFunctionWithCompletionNoDescCommand(t *testing.T) {
// Test that __complete command doesn't trigger default command logic
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The comment incorrectly states '__complete' when the test is for '__completeNoDesc'. Update to: 'Test that __completeNoDesc command doesn't trigger default command logic'.

Suggested change
// Test that __complete command doesn't trigger default command logic
// Test that __completeNoDesc command doesn't trigger default command logic

Copilot uses AI. Check for mistakes.
@mikefarah mikefarah merged commit 414a085 into mikefarah:master Jan 22, 2026
3 of 4 checks passed
arthurzam pushed a commit to gentoo-golang-dist/forgejo-runner that referenced this pull request Feb 8, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [forgejo-runner-service-yq](https://github.com/mikefarah/yq) | minor | `v4.50.1` → `v4.52.2` |

---

### Release Notes

<details>
<summary>mikefarah/yq (forgejo-runner-service-yq)</summary>

### [`v4.52.2`](https://github.com/mikefarah/yq/releases/tag/v4.52.2)

[Compare Source](mikefarah/yq@v4.52.1...v4.52.2)

- Fixed bad instructions file breaking go-install ([#&#8203;2587](mikefarah/yq#2587)) Thanks [@&#8203;theyoprst](https://github.com/theyoprst)
  - Fixed TOML table scope after comments ([#&#8203;2588](mikefarah/yq#2588)) Thanks [@&#8203;tomers](https://github.com/tomers)
  - Multiply uses a readonly context ([#&#8203;2558](mikefarah/yq#2558))
  - Fixed merge globbing wildcards in keys ([#&#8203;2564](mikefarah/yq#2564))
  - Fixing TOML subarray parsing issue ([#&#8203;2581](mikefarah/yq#2581))

### [`v4.52.1`](https://github.com/mikefarah/yq/releases/tag/v4.52.1): - TOML roundtrip and more!

[Compare Source](mikefarah/yq@v4.50.1...v4.52.1)

- TOML encoder support - you can now roundtrip! [#&#8203;1364](mikefarah/yq#1364)
  - Parent now supports negative indices, and added a 'root' command for referencing the top level document

  - Fixed scalar encoding for HCL

  - Add --yaml-compact-seq-indent / -c flag for compact sequence indentation ([#&#8203;2583](mikefarah/yq#2583)) Thanks [@&#8203;jfenal](https://github.com/jfenal)

  - Add symlink check to file rename util ([#&#8203;2576](mikefarah/yq#2576)) Thanks [@&#8203;Elias-elastisys](https://github.com/Elias-elastisys)

  - Powershell fixed default command used for \_\_completeNoDesc alias ([#&#8203;2568](mikefarah/yq#2568)) Thanks [@&#8203;teejaded](https://github.com/teejaded)

  - Unwrap scalars in shell output mode. ([#&#8203;2548](mikefarah/yq#2548)) Thanks [@&#8203;flintwinters](https://github.com/flintwinters)

  - Added K8S KYAML output format support ([#&#8203;2560](mikefarah/yq#2560)) Thanks [@&#8203;robbat2](https://github.com/robbat2)

  - Bumped dependencies

  - Special shout out to [@&#8203;ccoVeille](https://github.com/ccoVeille) for reviewing my PRs!

Thanks to everyone that contributed ❤️

</details>

---

### Configuration

📅 **Schedule**: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC), Automerge - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45Mi40IiwidXBkYXRlZEluVmVyIjoiNDIuOTIuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiS2luZC9EZXBlbmRlbmN5VXBkYXRlIiwicnVuLWVuZC10by1lbmQtdGVzdHMiXX0=-->

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1347
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
Co-authored-by: Renovate Bot <bot@kriese.eu>
Co-committed-by: Renovate Bot <bot@kriese.eu>
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 15, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mikefarah/yq](https://github.com/mikefarah/yq) | minor | `v4.50.1` → `v4.52.4` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>mikefarah/yq (mikefarah/yq)</summary>

### [`v4.52.4`](https://github.com/mikefarah/yq/releases/tag/v4.52.4)

[Compare Source](mikefarah/yq@v4.52.2...v4.52.4)

- Dropping windows/arm - no longer supported in cross-compile
  - Fixing comments in TOML arrays ([#&#8203;2592](mikefarah/yq#2592))
  - Bumped dependencies

### [`v4.52.2`](https://github.com/mikefarah/yq/releases/tag/v4.52.2)

[Compare Source](mikefarah/yq@v4.52.1...v4.52.2)

- Fixed bad instructions file breaking go-install ([#&#8203;2587](mikefarah/yq#2587)) Thanks [@&#8203;theyoprst](https://github.com/theyoprst)
  - Fixed TOML table scope after comments ([#&#8203;2588](mikefarah/yq#2588)) Thanks [@&#8203;tomers](https://github.com/tomers)
  - Multiply uses a readonly context ([#&#8203;2558](mikefarah/yq#2558))
  - Fixed merge globbing wildcards in keys ([#&#8203;2564](mikefarah/yq#2564))
  - Fixing TOML subarray parsing issue ([#&#8203;2581](mikefarah/yq#2581))

### [`v4.52.1`](https://github.com/mikefarah/yq/releases/tag/v4.52.1): - TOML roundtrip and more!

[Compare Source](mikefarah/yq@v4.50.1...v4.52.1)

- TOML encoder support - you can now roundtrip! [#&#8203;1364](mikefarah/yq#1364)
  - Parent now supports negative indices, and added a 'root' command for referencing the top level document

  - Fixed scalar encoding for HCL

  - Add --yaml-compact-seq-indent / -c flag for compact sequence indentation ([#&#8203;2583](mikefarah/yq#2583)) Thanks [@&#8203;jfenal](https://github.com/jfenal)

  - Add symlink check to file rename util ([#&#8203;2576](mikefarah/yq#2576)) Thanks [@&#8203;Elias-elastisys](https://github.com/Elias-elastisys)

  - Powershell fixed default command used for \_\_completeNoDesc alias ([#&#8203;2568](mikefarah/yq#2568)) Thanks [@&#8203;teejaded](https://github.com/teejaded)

  - Unwrap scalars in shell output mode. ([#&#8203;2548](mikefarah/yq#2548)) Thanks [@&#8203;flintwinters](https://github.com/flintwinters)

  - Added K8S KYAML output format support ([#&#8203;2560](mikefarah/yq#2560)) Thanks [@&#8203;robbat2](https://github.com/robbat2)

  - Bumped dependencies

  - Special shout out to [@&#8203;ccoVeille](https://github.com/ccoVeille) for reviewing my MRs!

Thanks to everyone that contributed ❤️

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45Ni4yIiwidXBkYXRlZEluVmVyIjoiNDMuMTAuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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.

Autocomplete not working on powershell on Windows

3 participants