@clerc/plugin-completions 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,24 @@
1
1
  import { Plugin } from "@clerc/core";
2
2
 
3
3
  //#region src/index.d.ts
4
+ declare module "@clerc/core" {
5
+ interface CommandCustomOptions {
6
+ /**
7
+ * Completions options for the command.
8
+ */
9
+ completions?: {
10
+ /**
11
+ * Whether to show the command in completions output.
12
+ *
13
+ * @default true
14
+ */
15
+ show?: boolean;
16
+ };
17
+ }
18
+ }
4
19
  interface CompletionsPluginOptions {
5
20
  /**
6
- * Whether to register the `install-completions` and `uninstall-completions` commands.
21
+ * Whether to register the `completions install` and `completions uninstall` commands.
7
22
  * @default true
8
23
  */
9
24
  managementCommands?: boolean;
package/dist/index.js CHANGED
@@ -63,12 +63,15 @@ async function getCompletion(cli, env) {
63
63
  const remainingArgs = inputArgv.slice(matchedParts.length);
64
64
  prefix = `${[command.name, ...remainingArgs].join(" ")} `;
65
65
  } else prefix = inputArgv.length > 0 ? `${inputArgv.join(" ")} ` : "";
66
- for (const c of cli._commands.values()) if (c.name.startsWith(prefix)) {
67
- const nextWord = c.name.slice(prefix.length).split(" ")[0];
68
- if (nextWord) candidates.push({
69
- name: nextWord,
70
- description: c.description
71
- });
66
+ for (const command$1 of cli._commands.values()) {
67
+ if (command$1.completions?.show === false) continue;
68
+ if (command$1.name.startsWith(prefix)) {
69
+ const nextWord = command$1.name.slice(prefix.length).split(" ")[0];
70
+ if (nextWord) candidates.push({
71
+ name: nextWord,
72
+ description: command$1.description
73
+ });
74
+ }
72
75
  }
73
76
  const uniqueCandidates = /* @__PURE__ */ new Map();
74
77
  for (const c of candidates) uniqueCandidates.set(c.name, c);
@@ -81,6 +84,7 @@ const completionsPlugin = (options = {}) => definePlugin({ setup: (cli) => {
81
84
  const { managementCommands = true } = options;
82
85
  if (managementCommands) {
83
86
  cli.command("completions install", "Install shell completions", {
87
+ help: { group: "completions" },
84
88
  flags: { shell: {
85
89
  description: "Shell type",
86
90
  type: String
@@ -96,11 +100,12 @@ const completionsPlugin = (options = {}) => definePlugin({ setup: (cli) => {
96
100
  shell
97
101
  });
98
102
  });
99
- cli.command("completions uninstall", "Uninstall shell completions").on("completions uninstall", async () => {
103
+ cli.command("completions uninstall", "Uninstall shell completions", { help: { group: "completions" } }).on("completions uninstall", async () => {
100
104
  await tabtab.uninstall({ name: cli._name });
101
105
  });
102
106
  }
103
107
  cli.command("completions", "Generate completions script", {
108
+ help: { group: "completions" },
104
109
  flags: { shell: {
105
110
  description: "Shell type",
106
111
  type: String
@@ -117,7 +122,7 @@ const completionsPlugin = (options = {}) => definePlugin({ setup: (cli) => {
117
122
  });
118
123
  console.log(script);
119
124
  });
120
- cli.command("completion-server", "Handle completions").on("completion-server", async () => {
125
+ cli.command("completion-server", "Handle completions", { help: { show: false } }).on("completion-server", async () => {
121
126
  const env = tabtab.parseEnv(process.env);
122
127
  if (!env.complete) return;
123
128
  const shell = getShellFromEnv(process.env);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/plugin-completions",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.3",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc plugin completions",
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@pnpm/tabtab": "^0.5.4",
49
- "@clerc/utils": "1.0.0-beta.1"
49
+ "@clerc/utils": "1.0.0-beta.3"
50
50
  },
51
51
  "devDependencies": {
52
- "@clerc/core": "1.0.0-beta.1"
52
+ "@clerc/core": "1.0.0-beta.3"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@clerc/core": "*"