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

[Bug] nushell completions arg type mismatch #572

Open
Kissaki opened this issue Nov 1, 2024 · 1 comment
Open

[Bug] nushell completions arg type mismatch #572

Kissaki opened this issue Nov 1, 2024 · 1 comment

Comments

@Kissaki
Copy link

Kissaki commented Nov 1, 2024

Describe the bug

completions nushell generates nushell completions with switch arguments of type string instead of int.

This conflicts with what I seem to see in the pueue sources (cli.rs) and the nu-scripts task.nu pueue wrapper that the official nu documentation references.

Steps to reproduce

pueue completions nushell | save -f pueue-completions.nu
use pueue-completions.nu *

http get https://raw.githubusercontent.com/nushell/nu_scripts/refs/heads/main/modules/background_task/task.nu | save -f task.nu
use task.nu
nu ❯ use task.nu                                                                                                                                         ~\temp
Error: nu::parser::type_mismatch

  × Type mismatch.
    ╭─[C:\Users\redacted\temp\task.nu:76:16]
 75 │ ] {
 76 │   pueue switch $task_id_1 $task_id_2
    ·                ─────┬────
    ·                     ╰── expected string, found int
 77 │ }
    ╰────


### Debug logs (if relevant)

_No response_

### Operating system

Windows 11

### Pueue version

3.4.1

### Additional context

In the generated nu code, for `switch` the parameter types are string

```nu
  export extern "pueue switch" [
    task_id_1: string         # The first task id
    task_id_2: string         # The second task id
    --help(-h)                # Print help
  ]

despite cli.rs defining usize types

Switch {
        /// The first task id.
        task_id_1: usize,
        /// The second task id.
        task_id_2: usize,
    }

That alone is not an issue for command line completions, albeit unspecific.

Nushell has a nu-scripts repository with a task module/custom command, and refers to pueue and task on the background tasks documentation. This command defines aliases and mappings to pueue commands. The switch command defines the parameters to be int types. When calling pueue switch this type conflicts with the string type generated by pueue completions and results in task.nu not being usable.

I tried to find the cause, diving into pueue and clip, cli.rs and the generate call. I'm not too familiar with Rust. When I found it seems to use macros and type information transformation I had to give up.

@Nukesor
Copy link
Owner

Nukesor commented Nov 2, 2024

Nushell autocompletion scripts are a relatively new feature and have been added by a community member @Tirka in #527

@Tirka could you take a stab at this, since I'm not using nushell myself :)

Kissaki added a commit to Kissaki/nushell-config that referenced this issue Nov 15, 2024
Conflicts with nu-scripts task command definition param type.

Open issue Nukesor/pueue#572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants