@optique/core 1.0.15-dev.2792 → 1.0.15-dev.2809

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.
@@ -913,6 +913,16 @@ complete -c ${programName} -f -a '(${functionName})'
913
913
  }
914
914
  };
915
915
  /**
916
+ * Quotes a string as a Nushell string literal. Nushell single-quoted strings
917
+ * have no escape sequences, so a value containing an apostrophe is written as
918
+ * a double-quoted string, in which only backslashes and double quotes need
919
+ * escaping.
920
+ */
921
+ function quoteNuString(value) {
922
+ if (!value.includes("'")) return `'${value}'`;
923
+ return `"${value.replace(/["\\]/g, "\\$&")}"`;
924
+ }
925
+ /**
916
926
  * The Nushell completion generator.
917
927
  * @since 0.6.0
918
928
  */
@@ -920,7 +930,7 @@ const nu = {
920
930
  name: "nu",
921
931
  generateScript(programName, args = []) {
922
932
  validateProgramName(programName);
923
- const escapedArgs = args.map((arg) => `'${arg.replace(/'/g, "''")}'`).join(" ");
933
+ const escapedArgs = args.map(quoteNuString).join(" ");
924
934
  const safeName = programName.replace(/[^a-zA-Z0-9]+/g, "-");
925
935
  const functionName = `nu-complete-${safeName}`;
926
936
  return `
@@ -913,6 +913,16 @@ complete -c ${programName} -f -a '(${functionName})'
913
913
  }
914
914
  };
915
915
  /**
916
+ * Quotes a string as a Nushell string literal. Nushell single-quoted strings
917
+ * have no escape sequences, so a value containing an apostrophe is written as
918
+ * a double-quoted string, in which only backslashes and double quotes need
919
+ * escaping.
920
+ */
921
+ function quoteNuString(value) {
922
+ if (!value.includes("'")) return `'${value}'`;
923
+ return `"${value.replace(/["\\]/g, "\\$&")}"`;
924
+ }
925
+ /**
916
926
  * The Nushell completion generator.
917
927
  * @since 0.6.0
918
928
  */
@@ -920,7 +930,7 @@ const nu = {
920
930
  name: "nu",
921
931
  generateScript(programName, args = []) {
922
932
  validateProgramName(programName);
923
- const escapedArgs = args.map((arg) => `'${arg.replace(/'/g, "''")}'`).join(" ");
933
+ const escapedArgs = args.map(quoteNuString).join(" ");
924
934
  const safeName = programName.replace(/[^a-zA-Z0-9]+/g, "-");
925
935
  const functionName = `nu-complete-${safeName}`;
926
936
  return `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.15-dev.2792",
3
+ "version": "1.0.15-dev.2809",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",