|
| 1 | +const ListModelGenerator: Fig.Generator = { |
| 2 | + script: ["bash", "-c", "ollama ls | awk '!/NAME/ { print $1 }'"], |
| 3 | + postProcess: (out) => out.trim().split("\n"), |
| 4 | +}; |
| 5 | + |
| 6 | +const RunModelGenerator: Fig.Generator = { |
| 7 | + script: ["bash", "-c", "ollama ps | awk '!/NAME/ { print $1 }'"], |
| 8 | + postProcess: (out) => out.trim().split("\n"), |
| 9 | +}; |
| 10 | + |
| 11 | +const completionSpec: Fig.Spec = { |
| 12 | + name: "ollama", |
| 13 | + description: |
| 14 | + "A command-line tool for managing and deploying machine learning models", |
| 15 | + subcommands: [ |
| 16 | + { |
| 17 | + name: "serve", |
| 18 | + description: "Start ollama", |
| 19 | + }, |
| 20 | + { |
| 21 | + name: "create", |
| 22 | + description: "Create a model from a Modelfile", |
| 23 | + options: [ |
| 24 | + { |
| 25 | + name: "-f", |
| 26 | + description: "Specify Modelfile", |
| 27 | + args: { |
| 28 | + name: "filename", |
| 29 | + template: "filepaths", |
| 30 | + }, |
| 31 | + }, |
| 32 | + ], |
| 33 | + }, |
| 34 | + { |
| 35 | + name: "show", |
| 36 | + description: "Show information for a model", |
| 37 | + args: { |
| 38 | + name: "model", |
| 39 | + generators: ListModelGenerator, |
| 40 | + }, |
| 41 | + }, |
| 42 | + { |
| 43 | + name: "run", |
| 44 | + description: "Run a model", |
| 45 | + args: { |
| 46 | + name: "model", |
| 47 | + generators: ListModelGenerator, |
| 48 | + }, |
| 49 | + options: [ |
| 50 | + { |
| 51 | + name: "--verbose", |
| 52 | + description: "Enable verbose output", |
| 53 | + }, |
| 54 | + ], |
| 55 | + }, |
| 56 | + { |
| 57 | + name: "stop", |
| 58 | + description: "Stop the ollama server", |
| 59 | + args: { |
| 60 | + name: "model", |
| 61 | + generators: RunModelGenerator, |
| 62 | + }, |
| 63 | + }, |
| 64 | + { |
| 65 | + name: "pull", |
| 66 | + description: "Pull a model from a registry", |
| 67 | + }, |
| 68 | + { |
| 69 | + name: "push", |
| 70 | + description: "Push a model to a registry", |
| 71 | + }, |
| 72 | + { |
| 73 | + name: ["list", "ls"], |
| 74 | + description: "List models", |
| 75 | + }, |
| 76 | + { |
| 77 | + name: "ps", |
| 78 | + description: "List running models", |
| 79 | + }, |
| 80 | + { |
| 81 | + name: "cp", |
| 82 | + description: "Copy a model", |
| 83 | + args: { |
| 84 | + name: "SOURCE", |
| 85 | + generators: ListModelGenerator, |
| 86 | + }, |
| 87 | + }, |
| 88 | + { |
| 89 | + name: "rm", |
| 90 | + description: "Remove a model", |
| 91 | + args: { |
| 92 | + name: "model", |
| 93 | + generators: ListModelGenerator, |
| 94 | + }, |
| 95 | + }, |
| 96 | + { |
| 97 | + name: "help", |
| 98 | + description: "Help about any command", |
| 99 | + subcommands: [ |
| 100 | + { |
| 101 | + name: "serve", |
| 102 | + description: "Start ollama", |
| 103 | + }, |
| 104 | + { |
| 105 | + name: "create", |
| 106 | + description: "Create a model from a Modelfile", |
| 107 | + }, |
| 108 | + { |
| 109 | + name: "show", |
| 110 | + description: "Show information for a model", |
| 111 | + }, |
| 112 | + { |
| 113 | + name: "run", |
| 114 | + description: "Run a model", |
| 115 | + }, |
| 116 | + { |
| 117 | + name: "stop", |
| 118 | + description: "Stop the ollama server", |
| 119 | + }, |
| 120 | + { |
| 121 | + name: "pull", |
| 122 | + description: "Pull a model from a registry", |
| 123 | + }, |
| 124 | + { |
| 125 | + name: "push", |
| 126 | + description: "Push a model to a registry", |
| 127 | + }, |
| 128 | + { |
| 129 | + name: "list", |
| 130 | + description: "List models", |
| 131 | + }, |
| 132 | + { |
| 133 | + name: "ps", |
| 134 | + description: "List running models", |
| 135 | + }, |
| 136 | + { |
| 137 | + name: "cp", |
| 138 | + description: "Copy a model", |
| 139 | + }, |
| 140 | + { |
| 141 | + name: "rm", |
| 142 | + description: "Remove a model", |
| 143 | + }, |
| 144 | + ], |
| 145 | + }, |
| 146 | + ], |
| 147 | + options: [ |
| 148 | + { |
| 149 | + name: ["--help", "-h"], |
| 150 | + description: "Show help for ollama", |
| 151 | + isPersistent: true, |
| 152 | + }, |
| 153 | + { |
| 154 | + name: ["--version", "-v"], |
| 155 | + description: "Show version information", |
| 156 | + }, |
| 157 | + ], |
| 158 | +}; |
| 159 | + |
| 160 | +export default completionSpec; |
0 commit comments