@optique/clack 1.2.0-dev.2194 → 1.2.0-dev.2198

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -0
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -59,7 +59,12 @@ async function executePromptRaw(config) {
59
59
  const prompts = getPromptFunctions();
60
60
  if ("prompter" in cfg && cfg.prompter != null) {
61
61
  const value = await cfg.prompter();
62
+ if (prompts.isCancel(value)) return {
63
+ success: false,
64
+ error: message`Prompt cancelled.`
65
+ };
62
66
  if (cfg.type === "number") return normalizeNumberResult(value);
67
+ if (cfg.type === "multiselect") return normalizeMultiselectResult(value, cfg);
63
68
  return {
64
69
  success: true,
65
70
  value
@@ -71,6 +76,7 @@ async function executePromptRaw(config) {
71
76
  error: message`Prompt cancelled.`
72
77
  };
73
78
  if (cfg.type === "number") return normalizeNumberResult(result);
79
+ if (cfg.type === "multiselect") return normalizeMultiselectResult(result, cfg);
74
80
  return {
75
81
  success: true,
76
82
  value: result
@@ -131,6 +137,16 @@ function normalizeNumberResult(result) {
131
137
  value: parsed
132
138
  };
133
139
  }
140
+ function normalizeMultiselectResult(result, config) {
141
+ if (config.required === true && Array.isArray(result) && result.length < 1) return {
142
+ success: false,
143
+ error: message`No option selected.`
144
+ };
145
+ return {
146
+ success: true,
147
+ value: result
148
+ };
149
+ }
134
150
  function parseNumberPromptValue(value) {
135
151
  if (value.trim() === "") return null;
136
152
  const parsed = Number(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/clack",
3
- "version": "1.2.0-dev.2194",
3
+ "version": "1.2.0-dev.2198",
4
4
  "description": "Interactive prompt support for Optique via Clack",
5
5
  "keywords": [
6
6
  "CLI",
@@ -57,16 +57,16 @@
57
57
  "sideEffects": false,
58
58
  "dependencies": {
59
59
  "@clack/prompts": "^1.6.0",
60
- "@optique/prompt": "1.2.0-dev.2194+96000f1d",
61
- "@optique/core": "1.2.0-dev.2194+96000f1d"
60
+ "@optique/core": "1.2.0-dev.2198+328dd530",
61
+ "@optique/prompt": "1.2.0-dev.2198+328dd530"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/node": "^24.0.0",
65
65
  "fast-check": "^4.7.0",
66
66
  "tsdown": "^0.13.0",
67
67
  "typescript": "^5.8.3",
68
- "@optique/run": "1.2.0-dev.2194+96000f1d",
69
- "@optique/env": "1.2.0-dev.2194+96000f1d"
68
+ "@optique/env": "1.2.0-dev.2198+328dd530",
69
+ "@optique/run": "1.2.0-dev.2198+328dd530"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsdown",