@getmonoceros/workbench 1.9.0 → 1.9.2
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/bin.js +47 -18
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -4428,7 +4428,7 @@ async function persistPromptedIdentity(prompted, ymlPath, home, logger) {
|
|
|
4428
4428
|
}
|
|
4429
4429
|
|
|
4430
4430
|
// src/version.ts
|
|
4431
|
-
var CLI_VERSION = true ? "1.9.
|
|
4431
|
+
var CLI_VERSION = true ? "1.9.2" : "dev";
|
|
4432
4432
|
|
|
4433
4433
|
// src/commands/_dispatch.ts
|
|
4434
4434
|
import { consola as consola12 } from "consola";
|
|
@@ -4487,6 +4487,13 @@ function renderCompletionScript(shell) {
|
|
|
4487
4487
|
' candidates=$(monoceros __complete --line "$COMP_LINE" --point "$COMP_POINT" 2>/dev/null)',
|
|
4488
4488
|
' local cur="${COMP_WORDS[COMP_CWORD]}"',
|
|
4489
4489
|
' COMPREPLY=( $(compgen -W "$candidates" -- "$cur") )',
|
|
4490
|
+
" # Suppress the trailing space when bash narrowed the candidate",
|
|
4491
|
+
" # set to a single token that ends with `=` \u2014 those are value-",
|
|
4492
|
+
" # flags (`--with=`, `--with-ports=`, \u2026) where the user types the",
|
|
4493
|
+
" # value immediately after.",
|
|
4494
|
+
' if [[ ${#COMPREPLY[@]} -eq 1 && "${COMPREPLY[0]}" == *= ]]; then',
|
|
4495
|
+
" compopt -o nospace",
|
|
4496
|
+
" fi",
|
|
4490
4497
|
"}",
|
|
4491
4498
|
"complete -F _monoceros monoceros",
|
|
4492
4499
|
""
|
|
@@ -4529,10 +4536,22 @@ function renderCompletionScript(shell) {
|
|
|
4529
4536
|
"_monoceros() {",
|
|
4530
4537
|
' local line="$BUFFER"',
|
|
4531
4538
|
' local point="$CURSOR"',
|
|
4532
|
-
" local -a candidates",
|
|
4539
|
+
" local -a candidates with_eq without_eq",
|
|
4533
4540
|
' candidates=("${(@f)$(monoceros __complete --line "$line" --point "$point" 2>/dev/null)}")',
|
|
4534
4541
|
' candidates=("${(@)candidates:#}")',
|
|
4535
|
-
|
|
4542
|
+
' # Split candidates into "ends with `=`" (value-flags \u2014 no suffix',
|
|
4543
|
+
" # space wanted because the user types the value immediately) and",
|
|
4544
|
+
' # "everything else" (positional values, boolean flags \u2014 default',
|
|
4545
|
+
" # space behaviour).",
|
|
4546
|
+
' for cand in "${candidates[@]}"; do',
|
|
4547
|
+
' if [[ "$cand" == *= ]]; then',
|
|
4548
|
+
' with_eq+=("$cand")',
|
|
4549
|
+
" else",
|
|
4550
|
+
' without_eq+=("$cand")',
|
|
4551
|
+
" fi",
|
|
4552
|
+
" done",
|
|
4553
|
+
" (( ${#with_eq[@]} )) && compadd -S '' -- \"${with_eq[@]}\"",
|
|
4554
|
+
' (( ${#without_eq[@]} )) && compadd -- "${without_eq[@]}"',
|
|
4536
4555
|
"}",
|
|
4537
4556
|
"",
|
|
4538
4557
|
'_monoceros "$@"',
|
|
@@ -4709,7 +4728,6 @@ function isShellWhitespace(ch) {
|
|
|
4709
4728
|
function dispatchCommand(spec, argTokens, ctx) {
|
|
4710
4729
|
const dashDashIdx = argTokens.indexOf("--");
|
|
4711
4730
|
const preDash = dashDashIdx < 0 ? argTokens : argTokens.slice(0, dashDashIdx);
|
|
4712
|
-
const postDash = dashDashIdx < 0 ? [] : argTokens.slice(dashDashIdx + 1);
|
|
4713
4731
|
const inPostDash = dashDashIdx >= 0;
|
|
4714
4732
|
if (inPostDash && spec.innerArgs) {
|
|
4715
4733
|
return resolveValues(spec.innerArgs, ctx, ctx.current);
|
|
@@ -4728,14 +4746,7 @@ async function resolvePreDash(spec, preDash, ctx) {
|
|
|
4728
4746
|
return completions.map((v) => `${flagName}=${v}`);
|
|
4729
4747
|
}
|
|
4730
4748
|
if (current.startsWith("-")) {
|
|
4731
|
-
|
|
4732
|
-
const names = Object.keys(flags);
|
|
4733
|
-
const all = [];
|
|
4734
|
-
for (const n of names) {
|
|
4735
|
-
all.push(n);
|
|
4736
|
-
for (const a of flags[n].aliases ?? []) all.push(a);
|
|
4737
|
-
}
|
|
4738
|
-
return filterPrefix(all, current);
|
|
4749
|
+
return listFlagNames(spec.flags ?? {}, current);
|
|
4739
4750
|
}
|
|
4740
4751
|
const lastPrev = preDash[preDash.length - 1];
|
|
4741
4752
|
if (lastPrev && lastPrev.startsWith("--") && !lastPrev.includes("=")) {
|
|
@@ -4745,12 +4756,25 @@ async function resolvePreDash(spec, preDash, ctx) {
|
|
|
4745
4756
|
}
|
|
4746
4757
|
}
|
|
4747
4758
|
const positionalIdx = countCompletedPositionals(preDash, spec.flags ?? {});
|
|
4748
|
-
const
|
|
4749
|
-
|
|
4750
|
-
|
|
4759
|
+
const positionals = spec.positionals ?? [];
|
|
4760
|
+
const expectedPositionalCount = spec.positionalCount ?? positionals.length;
|
|
4761
|
+
if (positionalIdx < positionals.length) {
|
|
4762
|
+
const positional = positionals[positionalIdx];
|
|
4763
|
+
if (positional) return resolveValues(positional, ctx, current);
|
|
4764
|
+
}
|
|
4765
|
+
if (positionalIdx >= expectedPositionalCount) {
|
|
4766
|
+
return listFlagNames(spec.flags ?? {}, current);
|
|
4751
4767
|
}
|
|
4752
4768
|
return [];
|
|
4753
4769
|
}
|
|
4770
|
+
function listFlagNames(flags, fragment) {
|
|
4771
|
+
const names = [];
|
|
4772
|
+
for (const [name, spec] of Object.entries(flags)) {
|
|
4773
|
+
names.push(spec.type === "value" ? `${name}=` : name);
|
|
4774
|
+
for (const alias of spec.aliases ?? []) names.push(alias);
|
|
4775
|
+
}
|
|
4776
|
+
return filterPrefix(names, fragment);
|
|
4777
|
+
}
|
|
4754
4778
|
function countCompletedPositionals(preDash, flags) {
|
|
4755
4779
|
let count = 0;
|
|
4756
4780
|
for (let i = 0; i < preDash.length; i++) {
|
|
@@ -4892,8 +4916,11 @@ var ALL_COMMANDS = [
|
|
|
4892
4916
|
var containerName = (ctx) => listContainerNames(ctx);
|
|
4893
4917
|
var COMMAND_SPECS = {
|
|
4894
4918
|
init: {
|
|
4895
|
-
// First positional is a FRESH name → no
|
|
4896
|
-
//
|
|
4919
|
+
// First positional is a FRESH name → no suggestion source, but
|
|
4920
|
+
// the slot exists. Once the cursor is past it (after the name +
|
|
4921
|
+
// space), `--with` / `--with-repo` / `--with-ports` surface as
|
|
4922
|
+
// flag suggestions.
|
|
4923
|
+
positionalCount: 1,
|
|
4897
4924
|
flags: {
|
|
4898
4925
|
"--with": { type: "value", values: () => listAllCatalogComponents() },
|
|
4899
4926
|
"--with-repo": { type: "value" },
|
|
@@ -4984,7 +5011,9 @@ var COMMAND_SPECS = {
|
|
|
4984
5011
|
"list-components": {},
|
|
4985
5012
|
restore: {
|
|
4986
5013
|
// First positional is a backup-path; no value suggestions today
|
|
4987
|
-
// (could plug filesystem completion later).
|
|
5014
|
+
// (could plug filesystem completion later). Slot still exists so
|
|
5015
|
+
// Tab is silent inside it rather than offering flags prematurely.
|
|
5016
|
+
positionalCount: 1
|
|
4988
5017
|
}
|
|
4989
5018
|
};
|
|
4990
5019
|
var COMPLETION_COMMAND_SPEC_KEYS = Object.keys(COMMAND_SPECS);
|