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

generate completions from tree-shaped data #683

Merged
merged 1 commit into from
Dec 2, 2023
Merged

Conversation

fj0r
Copy link
Contributor

@fj0r fj0r commented Dec 2, 2023

it might be too trivial to manually create a completion. in many scenarios, completion is a tree-shaped structure - the current candidate is influenced by the previous candidate.

completion-generator generate completion through tree-like structures

def test [...args:string@com-test] {}

def com-test [...context] {
    $context | completion-generator from tree {
        a: {
            b: {
                c: {
                    d: 1
                    e: 2
                }
            }
            f: [g h i]
        }
        j: {|path| [k l m]}
        n: [
            {value: o, description: .., next: [p q]}
            {value: r, description: .., next: {s: t, u: v, w: x}}
        ]
    }
}

it uses existing positional arguments as a breadcrumbs to select candidates in tree structures

as an example, completion-generator flare to create completion from online json data

completion-generator supports different structural expressions

{value: desc}
{value: { next : ...}
[a b c ...]
[{value: a, description: b, next: [...]]
{|path| ...}

these different structures allow any kind of nesting

it might be too trivial to manually create a completion.
in many scenarios, completion is a tree-shaped structure - the current candidate is influenced by the previous candidate.

`completion-generator` generate completion through tree-like structures
````
{a: {b: {c: {d: 1 e: 2}
````
it uses existing positional arguments as a breadcrumbs to select candidates in tree structures

as an example, `completion-generator flare` to create completion from online json data

`completion-generator` supports different structural expressions
````
{value: desc}
{value: { next : ...}
[a b c ...]
[{value: a, description: b, next: [...]]
{|path| ...}
````

these different structures allow any kind of nesting
@fdncred fdncred merged commit 55ef44a into nushell:main Dec 2, 2023
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.

None yet

3 participants