carapace-sh / carapace-bin

multi-shell multi-command argument completer
https://carapace.sh
MIT License
972 stars 54 forks source link

mycmd: Custom spec from example doesn't work for me #2332

Closed hustcer closed 8 months ago

hustcer commented 8 months ago

Current Behavior

I just tried the example from Spec, however it doesn't work for me.

Expected Behavior

It should work as the asciinema casts

Steps To Reproduce

  1. $ cat ~/.config/carapace/specs/mycmd.yaml
    # yaml-language-server: $schema=https://carapace.sh/schemas/command.json
    name: mycmd
    description: my command
    flags:
    --optarg?: optarg flag
    -r, --repeatable*: repeatable flag
    -v=: flag with value
    persistentflags:
    --help: bool flag
    completion:
    flag:
    optarg: ["one", "two\twith description", "three\twith style\tblue"]
    v: ["$files"]
    commands:
    - name: sub
    description: subcommand
    completion:
    positional:
      - ["$list(,)", "1", "2", "3"]
      - ["$directories"]
  2. Run source <(carapace _carapace) in bash
  3. Input mycmd in commandline and press Tab, however, nothing appears

Version

1.0.0

OS

Shell

Anything else?

$ cat ~/.config/carapace/specs/git.yaml

# yaml-language-server: $schema=https://carapace.sh/schemas/command.json
name:  git
description: the stupid content tracker
parsing: disabled
completion:
  positionalany: ["$carapace.bridge.Fish([git])"]

The git completion works for me in bash

rsteube commented 8 months ago

Can you check from where the specs are loaded?

carapace -h
# Specs are loaded from ...

Unless XDG_CONFIG_HOME is set the default path in osx is ~/Library/Application Support/carapace/specs.

hustcer commented 8 months ago

Shell parameter is optional and if left out carapace will try to detect it by parent process name. Some completions are cached at [/Users/hustcer/Library/Caches/carapace]. Config is written to [/Users/hustcer/Library/Application Support/carapace]. Specs are loaded from [/Users/hustcer/Library/Application Support/carapace/specs].

I have just copied mycmd.yaml to /Users/hustcer/Library/Application Support/carapace/specs and ran source <(carapace _carapace), still has no luck

rsteube commented 8 months ago

Is it limited to bash? The default version in osx is quite ancient. You can update it with homebrew:

brew install bash