@shell-shock/plugin-completions 0.2.3 → 0.2.7

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 (47) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +3 -0
  2. package/dist/components/bash-command.cjs +59 -58
  3. package/dist/components/bash-command.d.cts +2 -2
  4. package/dist/components/bash-command.d.cts.map +1 -1
  5. package/dist/components/bash-command.d.mts +2 -2
  6. package/dist/components/bash-command.d.mts.map +1 -1
  7. package/dist/components/bash-command.mjs.map +1 -1
  8. package/dist/components/fish-command.cjs +124 -123
  9. package/dist/components/fish-command.d.cts +2 -2
  10. package/dist/components/fish-command.d.cts.map +1 -1
  11. package/dist/components/fish-command.d.mts.map +1 -1
  12. package/dist/components/fish-command.mjs.map +1 -1
  13. package/dist/components/index.cjs +1 -0
  14. package/dist/components/powershell-command.cjs +82 -81
  15. package/dist/components/powershell-command.d.cts.map +1 -1
  16. package/dist/components/powershell-command.d.mts +2 -2
  17. package/dist/components/powershell-command.d.mts.map +1 -1
  18. package/dist/components/powershell-command.mjs +1 -1
  19. package/dist/components/powershell-command.mjs.map +1 -1
  20. package/dist/components/zsh-command.cjs +91 -90
  21. package/dist/components/zsh-command.d.cts.map +1 -1
  22. package/dist/components/zsh-command.d.mts.map +1 -1
  23. package/dist/components/zsh-command.mjs.map +1 -1
  24. package/dist/helpers/complete-command.cjs +1 -0
  25. package/dist/helpers/complete-command.d.cts.map +1 -1
  26. package/dist/helpers/complete-command.d.mts.map +1 -1
  27. package/dist/helpers/complete-command.mjs.map +1 -1
  28. package/dist/helpers/completion-directive-constants.cjs +1 -0
  29. package/dist/helpers/completion-directive-constants.d.cts.map +1 -1
  30. package/dist/helpers/completion-directive-constants.d.mts.map +1 -1
  31. package/dist/helpers/completion-directive-constants.mjs.map +1 -1
  32. package/dist/helpers/index.cjs +1 -0
  33. package/dist/index.cjs +22 -23
  34. package/dist/index.d.cts +0 -1
  35. package/dist/index.d.cts.map +1 -1
  36. package/dist/index.d.mts +0 -1
  37. package/dist/index.d.mts.map +1 -1
  38. package/dist/index.mjs +1 -2
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/types/index.cjs +1 -0
  41. package/dist/types/plugin.d.cts.map +1 -1
  42. package/dist/types/plugin.d.mts.map +1 -1
  43. package/dist/types/shell-type.cjs +1 -0
  44. package/dist/types/shell-type.d.cts.map +1 -1
  45. package/dist/types/shell-type.d.mts.map +1 -1
  46. package/dist/types/shell-type.mjs.map +1 -1
  47. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"powershell-command.mjs","names":["code","FunctionDeclaration","IfStatement","InterfaceDeclaration","VarDeclaration","ReflectionKind","Spacing","usePowerlines","InterfaceMember","TypescriptFile","TSDoc","TSDocDefaultValue","TSDocRemarks","getAppBin","getAppTitle","joinPaths","camelCase","snakeCase","exec","CompletionDirective","PowerShellCompletionsCommand","context","_$createComponent","path","entryPath","imports","builtinImports","children","heading","name","type","string","defaultValue","optional","async","parameters","initializer","CompletionDirectiveError","CompletionDirectiveNoSpace","CompletionDirectiveNoFileComp","CompletionDirectiveFilterFileExt","CompletionDirectiveFilterDirs","CompletionDirectiveKeepOrder","condition","_$memo"],"sources":["../../src/components/powershell-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocRemarks\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { exec } from \"../helpers/complete-command\";\nimport { CompletionDirective } from \"../helpers/completion-directive-constants\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function PowerShellCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": [\"os\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\n \"colors\",\n \"writeLine\",\n \"success\",\n \"warn\",\n \"stripAnsi\"\n ]\n }}>\n <TSDoc heading=\"Options for the PowerShell completions command.\" />\n <InterfaceDeclaration export name=\"PowerShellCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.ps1\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.ps1`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The PowerShell configuration file to append the completion script to.\">\n <TSDocRemarks>{`The generated completion script will be appended to the specified configuration file. Possible values for the PowerShell configuration file include: \\\\n- \\`~/.config/powershell/Microsoft.PowerShell_profile.ps1\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.config/powershell/Microsoft.PowerShell_profile.ps1\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions powershell\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n { name: \"options\", type: \"PowerShellCompletionsOptions\" }\n ]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`# powershell completion for ${getAppTitle(context)} -*- shell-script -*-\n\n [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n function __${snakeCase(getAppBin(context))}_debug {\n if ($env:BASH_COMP_DEBUG_FILE) {\n \"$args\" | Out-File -Append -FilePath \"$env:BASH_COMP_DEBUG_FILE\"\n }\n }\n\n filter __${camelCase(getAppBin(context))}_escapeStringWithSpecialChars {\n $_ -replace '\\\\s|#|@|\\\\$|;|,|''|\\\\{|\\\\}|\\\\(|\\\\)|\"|\\\\||<|>|&','\\`$&'\n }\n\n[scriptblock]$__${camelCase(getAppBin(context))}CompleterBlock = {\n param(\n $WordToComplete,\n $CommandAst,\n $CursorPosition\n )\n\n # Get the current command line and convert into a string\n $Command = $CommandAst.CommandElements\n $Command = \"$Command\"\n\n __${camelCase(getAppBin(context))}_debug \"\"\n __${camelCase(getAppBin(context))}_debug \"========= starting completion logic ==========\"\n __${camelCase(getAppBin(context))}_debug \"WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition\"\n\n # The user could have moved the cursor backwards on the command-line.\n # We need to trigger completion from the $CursorPosition location, so we need\n # to truncate the command-line ($Command) up to the $CursorPosition location.\n # Make sure the $Command is longer then the $CursorPosition before we truncate.\n # This happens because the $Command does not include the last space.\n if ($Command.Length -gt $CursorPosition) {\n $Command = $Command.Substring(0, $CursorPosition)\n }\n __${camelCase(getAppBin(context))}_debug \"Truncated command: $Command\"\n\n $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\n $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}\n $ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n $ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n $ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n $ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n # Prepare the command to request completions for the program.\n # Split the command at the first space to separate the program and arguments.\n $Program, $Arguments = $Command.Split(\" \", 2)\n\n $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { \"'\" + ($_ -replace \"'\", \"''\") + \"'\" }) -join ' '\n __${camelCase(getAppBin(context))}_debug \"QuotedArgs: $QuotedArgs\"\n\n $RequestComp = \"& ${exec} complete '--' $QuotedArgs\"\n __${camelCase(getAppBin(context))}_debug \"RequestComp: $RequestComp\"\n\n # we cannot use $WordToComplete because it\n # has the wrong values if the cursor was moved\n # so use the last argument\n if ($WordToComplete -ne \"\" ) {\n $WordToComplete = $Arguments.Split(\" \")[-1]\n }\n __${camelCase(getAppBin(context))}_debug \"New WordToComplete: $WordToComplete\"\n\n\n # Check for flag with equal sign\n $IsEqualFlag = ($WordToComplete -Like \"--*=*\" )\n if ( $IsEqualFlag ) {\n __${camelCase(getAppBin(context))}_debug \"Completing equal sign flag\"\n # Remove the flag part\n $Flag, $WordToComplete = $WordToComplete.Split(\"=\", 2)\n }\n\n if ( $WordToComplete -eq \"\" -And ( -Not $IsEqualFlag )) {\n # If the last parameter is complete (there is a space following it)\n # We add an extra empty parameter so we can indicate this to the go method.\n __${camelCase(getAppBin(context))}_debug \"Adding extra empty parameter\"\n # PowerShell 7.2+ changed the way how the arguments are passed to executables,\n # so for pre-7.2 or when Legacy argument passing is enabled we need to use\n if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or\n ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -or\n (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -and\n $PSNativeCommandArgumentPassing -eq 'Legacy')) {\n $RequestComp=\"$RequestComp\" + ' \\`\"\\`\"'\n } else {\n $RequestComp = \"$RequestComp\" + ' \"\"'\n }\n }\n\n __${camelCase(getAppBin(context))}_debug \"Calling $RequestComp\"\n # First disable ActiveHelp which is not supported for Powershell\n $env:ActiveHelp = 0\n\n # call the command store the output in $out and redirect stderr and stdout to null\n # $Out is an array contains each line per element\n Invoke-Expression -OutVariable out \"$RequestComp\" 2>&1 | Out-Null\n\n # get directive from last line\n [int]$Directive = $Out[-1].TrimStart(':')\n if ($Directive -eq \"\") {\n # There is no directive specified\n $Directive = 0\n }\n __${camelCase(getAppBin(context))}_debug \"The completion directive is: $Directive\"\n\n # remove directive (last element) from out\n $Out = $Out | Where-Object { $_ -ne $Out[-1] }\n __${camelCase(getAppBin(context))}_debug \"The completions are: $Out\"\n if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {\n # Error code. No completion.\n __${camelCase(getAppBin(context))}_debug \"Received error from custom completion go code\"\n return\n }\n\n $Longest = 0\n [Array]$Values = $Out | ForEach-Object {\n # Split the output in name and description\n $Name, $Description = $_.Split(\"\\`t\", 2)\n __${camelCase(getAppBin(context))}_debug \"Name: $Name Description: $Description\"\n\n # Look for the longest completion so that we can format things nicely\n if ($Longest -lt $Name.Length) {\n $Longest = $Name.Length\n }\n\n # Set the description to a one space string if there is none set.\n # This is needed because the CompletionResult does not accept an empty string as argument\n if (-Not $Description) {\n $Description = \" \"\n }\n @{ Name = \"$Name\"; Description = \"$Description\" }\n }\n\n\n $Space = \" \"\n if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {\n # remove the space here\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveNoSpace is called\"\n $Space = \"\"\n }\n\n if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or\n (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported\"\n\n # return here to prevent the completion of the extensions\n return\n }\n\n $Values = $Values | Where-Object {\n # filter the result\n $_.Name -like \"$WordToComplete*\"\n\n # Join the flag back if we have an equal sign flag\n if ( $IsEqualFlag ) {\n __${camelCase(getAppBin(context))}_debug \"Join the equal sign flag back to the completion value\"\n $_.Name = $Flag + \"=\" + $_.Name\n }\n }\n\n # we sort the values in ascending order by name if keep order isn't passed\n if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {\n $Values = $Values | Sort-Object -Property Name\n }\n\n if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveNoFileComp is called\"\n\n if ($Values.Length -eq 0) {\n # Just print an empty string here so the\n # shell does not start to complete paths.\n # We cannot use CompletionResult here because\n # it does not accept an empty string as argument.\n \"\"\n return\n }\n }\n\n # Get the current mode\n $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq \"Tab\" }).Function\n __${camelCase(getAppBin(context))}_debug \"Mode: $Mode\"\n\n $Values | ForEach-Object {\n\n # store temporary because switch will overwrite $_\n $comp = $_\n\n # PowerShell supports three different completion modes\n # - TabCompleteNext (default windows style - on each key press the next option is displayed)\n # - Complete (works like bash)\n # - MenuComplete (works like zsh)\n # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>\n\n # CompletionResult Arguments:\n # 1) CompletionText text to be used as the auto completion result\n # 2) ListItemText text to be displayed in the suggestion list\n # 3) ResultType type of completion result\n # 4) ToolTip text for the tooltip with details about the object\n\n switch ($Mode) {\n\n # bash like\n \"Complete\" {\n\n if ($Values.Length -eq 1) {\n __${camelCase(\n getAppBin(context)\n )}_debug \"Only one completion left\"\n\n # insert space after value\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n\n } else {\n # Add the proper number of spaces to align the descriptions\n while($comp.Name.Length -lt $Longest) {\n $comp.Name = $comp.Name + \" \"\n }\n\n # Check for empty description and only add parentheses if needed\n if ($($comp.Description) -eq \" \" ) {\n $Description = \"\"\n } else {\n $Description = \" ($($comp.Description))\"\n }\n\n [System.Management.Automation.CompletionResult]::new(\"$($comp.Name)$Description\", \"$($comp.Name)$Description\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n # zsh like\n \"MenuComplete\" {\n # insert space after value\n # MenuComplete will automatically show the ToolTip of\n # the highlighted value at the bottom of the suggestions.\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n\n # TabCompleteNext and in case we get something unknown\n Default {\n # Like MenuComplete but we don't want to add a space here because\n # the user need to press space anyway to get the completion.\n # Description will not be shown because that's not possible with TabCompleteNext\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars), \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n }\n}\n\nRegister-ArgumentCompleter -CommandName '${getAppBin(\n context\n )}' -ScriptBlock $__${camelCase(getAppBin(context))}CompleterBlock\n\\`); `}\n />\n <Spacing />\n <IfStatement condition={code`options.config`}>\n <VarDeclaration\n let\n name=\"configFilePath\"\n type=\"string\"\n initializer={code`options.config === true ? \"~/.config/powershell/Microsoft.PowerShell_profile.ps1\" : options.config`}\n />\n <Spacing />\n <IfStatement condition={code`configFilePath.startsWith(\"~\")`}>\n {code`configFilePath = join(os.homedir(), configFilePath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"configFileContent\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n configFileContent = await readFile(configFilePath, \"utf8\");\n } catch (error) {\n if (error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configFilePath, \\`\\${configFileContent}\\\\n\\\\n\\${stripAnsi(completions)}\\`);\n\n success(\\`${getAppTitle(context)} PowerShell completion script has been generated and appended to \\${colors.bold(configFilePath)}. Please restart your terminal or run \\`source \\${configFilePath}\\` to apply the changes.\\`); `}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`options.script`}>\n {code`const outputPath = options.script === true ? \"${getAppBin(context)}-completions.powershell\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} PowerShell completion script has been generated at \\${colors.bold(outputPath)}.\\`);`}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`!options.config && !options.script`}>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(completions);\n writeLine(\" ------------------------------------------------- \");`}\n </IfStatement>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgDA,SAAgBoB,+BAA+B;CAC7C,MAAMC,UAAUd,eAAyC;AAEzD,QAAAe,gBACGb,gBAAc;EAAA,IACbc,OAAI;AAAA,UAAER,UACJM,QAAQG,WACR,eACA,cACA,aACD;;EACDC,SAAS;GACP,WAAW,CAAC,KAAK;GACjB,oBAAoB,CAAC,YAAY,YAAW;GAC7C;EACDC,gBAAgB,EACd,uBAAuB;GACrB;GACA;GACA;GACA;GACA;GAAW,EAEd;EAAA,IAAAC,WAAA;AAAA,UAAA;IAAAL,gBACAZ,OAAK,EAACkB,SAAO,mDAAA,CAAA;IAAAN,gBACbnB,sBAAoB;KAAA,UAAA;KAAQ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version":3,"file":"powershell-command.mjs","names":[],"sources":["../../src/components/powershell-command.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n IfStatement,\n InterfaceDeclaration,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InterfaceMember,\n TypescriptFile\n} from \"@powerlines/plugin-alloy/typescript\";\nimport {\n TSDoc,\n TSDocDefaultValue,\n TSDocRemarks\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppBin, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport { exec } from \"../helpers/complete-command\";\nimport { CompletionDirective } from \"../helpers/completion-directive-constants\";\nimport type { CompletionsPluginContext } from \"../types/plugin\";\n\n/**\n * The PowerShell Completions commands' handler wrapper for the Shell Shock project.\n */\nexport function PowerShellCompletionsCommand() {\n const context = usePowerlines<CompletionsPluginContext>();\n\n return (\n <TypescriptFile\n path={joinPaths(\n context.entryPath,\n \"completions\",\n \"powershell\",\n \"command.ts\"\n )}\n imports={{\n \"node:os\": [\"os\"],\n \"node:fs/promises\": [\"readFile\", \"writeFile\"]\n }}\n builtinImports={{\n \"shell-shock:console\": [\n \"colors\",\n \"writeLine\",\n \"success\",\n \"warn\",\n \"stripAnsi\"\n ]\n }}>\n <TSDoc heading=\"Options for the PowerShell completions command.\" />\n <InterfaceDeclaration export name=\"PowerShellCompletionsOptions\">\n <TSDoc heading=\"The path to write the completion script to.\">\n <TSDocRemarks>{`If no extension is provided, the \\`.ps1\\` extension will be used.`}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue={`${getAppBin(context)}-completions.ps1`}\n />\n </TSDoc>\n <InterfaceMember name=\"script\" optional type=\"string | true\" />\n <Spacing />\n <TSDoc heading=\"The PowerShell configuration file to append the completion script to.\">\n <TSDocRemarks>{`The generated completion script will be appended to the specified configuration file. Possible values for the PowerShell configuration file include: \\\\n- \\`~/.config/powershell/Microsoft.PowerShell_profile.ps1\\``}</TSDocRemarks>\n <TSDocDefaultValue\n type={ReflectionKind.string}\n defaultValue=\"~/.config/powershell/Microsoft.PowerShell_profile.ps1\"\n />\n </TSDoc>\n <InterfaceMember name=\"config\" optional type=\"string | true\" />\n </InterfaceDeclaration>\n <Spacing />\n <TSDoc heading=\"Handler logic for the \\`completions powershell\\` command.\"></TSDoc>\n <FunctionDeclaration\n export\n default\n async\n name=\"handler\"\n parameters={[\n { name: \"options\", type: \"PowerShellCompletionsOptions\" }\n ]}>\n <VarDeclaration\n const\n name=\"completions\"\n type=\"string\"\n initializer={code`# powershell completion for ${getAppTitle(context)} -*- shell-script -*-\n\n [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n function __${snakeCase(getAppBin(context))}_debug {\n if ($env:BASH_COMP_DEBUG_FILE) {\n \"$args\" | Out-File -Append -FilePath \"$env:BASH_COMP_DEBUG_FILE\"\n }\n }\n\n filter __${camelCase(getAppBin(context))}_escapeStringWithSpecialChars {\n $_ -replace '\\\\s|#|@|\\\\$|;|,|''|\\\\{|\\\\}|\\\\(|\\\\)|\"|\\\\||<|>|&','\\`$&'\n }\n\n[scriptblock]$__${camelCase(getAppBin(context))}CompleterBlock = {\n param(\n $WordToComplete,\n $CommandAst,\n $CursorPosition\n )\n\n # Get the current command-line and convert into a string\n $Command = $CommandAst.CommandElements\n $Command = \"$Command\"\n\n __${camelCase(getAppBin(context))}_debug \"\"\n __${camelCase(getAppBin(context))}_debug \"========= starting completion logic ==========\"\n __${camelCase(getAppBin(context))}_debug \"WordToComplete: $WordToComplete Command: $Command CursorPosition: $CursorPosition\"\n\n # The user could have moved the cursor backwards on the command-line.\n # We need to trigger completion from the $CursorPosition location, so we need\n # to truncate the command-line ($Command) up to the $CursorPosition location.\n # Make sure the $Command is longer then the $CursorPosition before we truncate.\n # This happens because the $Command does not include the last space.\n if ($Command.Length -gt $CursorPosition) {\n $Command = $Command.Substring(0, $CursorPosition)\n }\n __${camelCase(getAppBin(context))}_debug \"Truncated command: $Command\"\n\n $ShellCompDirectiveError=${CompletionDirective.CompletionDirectiveError}\n $ShellCompDirectiveNoSpace=${CompletionDirective.CompletionDirectiveNoSpace}\n $ShellCompDirectiveNoFileComp=${\n CompletionDirective.CompletionDirectiveNoFileComp\n }\n $ShellCompDirectiveFilterFileExt=${\n CompletionDirective.CompletionDirectiveFilterFileExt\n }\n $ShellCompDirectiveFilterDirs=${\n CompletionDirective.CompletionDirectiveFilterDirs\n }\n $ShellCompDirectiveKeepOrder=${\n CompletionDirective.CompletionDirectiveKeepOrder\n }\n\n # Prepare the command to request completions for the program.\n # Split the command at the first space to separate the program and arguments.\n $Program, $Arguments = $Command.Split(\" \", 2)\n\n $QuotedArgs = ($Arguments -split ' ' | ForEach-Object { \"'\" + ($_ -replace \"'\", \"''\") + \"'\" }) -join ' '\n __${camelCase(getAppBin(context))}_debug \"QuotedArgs: $QuotedArgs\"\n\n $RequestComp = \"& ${exec} complete '--' $QuotedArgs\"\n __${camelCase(getAppBin(context))}_debug \"RequestComp: $RequestComp\"\n\n # we cannot use $WordToComplete because it\n # has the wrong values if the cursor was moved\n # so use the last argument\n if ($WordToComplete -ne \"\" ) {\n $WordToComplete = $Arguments.Split(\" \")[-1]\n }\n __${camelCase(getAppBin(context))}_debug \"New WordToComplete: $WordToComplete\"\n\n\n # Check for flag with equal sign\n $IsEqualFlag = ($WordToComplete -Like \"--*=*\" )\n if ( $IsEqualFlag ) {\n __${camelCase(getAppBin(context))}_debug \"Completing equal sign flag\"\n # Remove the flag part\n $Flag, $WordToComplete = $WordToComplete.Split(\"=\", 2)\n }\n\n if ( $WordToComplete -eq \"\" -And ( -Not $IsEqualFlag )) {\n # If the last parameter is complete (there is a space following it)\n # We add an extra empty parameter so we can indicate this to the go method.\n __${camelCase(getAppBin(context))}_debug \"Adding extra empty parameter\"\n # PowerShell 7.2+ changed the way how the arguments are passed to executables,\n # so for pre-7.2 or when Legacy argument passing is enabled we need to use\n if ($PSVersionTable.PsVersion -lt [version]'7.2.0' -or\n ($PSVersionTable.PsVersion -lt [version]'7.3.0' -and -not [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -or\n (($PSVersionTable.PsVersion -ge [version]'7.3.0' -or [ExperimentalFeature]::IsEnabled(\"PSNativeCommandArgumentPassing\")) -and\n $PSNativeCommandArgumentPassing -eq 'Legacy')) {\n $RequestComp=\"$RequestComp\" + ' \\`\"\\`\"'\n } else {\n $RequestComp = \"$RequestComp\" + ' \"\"'\n }\n }\n\n __${camelCase(getAppBin(context))}_debug \"Calling $RequestComp\"\n # First disable ActiveHelp which is not supported for Powershell\n $env:ActiveHelp = 0\n\n # call the command store the output in $out and redirect stderr and stdout to null\n # $Out is an array contains each line per element\n Invoke-Expression -OutVariable out \"$RequestComp\" 2>&1 | Out-Null\n\n # get directive from last line\n [int]$Directive = $Out[-1].TrimStart(':')\n if ($Directive -eq \"\") {\n # There is no directive specified\n $Directive = 0\n }\n __${camelCase(getAppBin(context))}_debug \"The completion directive is: $Directive\"\n\n # remove directive (last element) from out\n $Out = $Out | Where-Object { $_ -ne $Out[-1] }\n __${camelCase(getAppBin(context))}_debug \"The completions are: $Out\"\n if (($Directive -band $ShellCompDirectiveError) -ne 0 ) {\n # Error code. No completion.\n __${camelCase(getAppBin(context))}_debug \"Received error from custom completion go code\"\n return\n }\n\n $Longest = 0\n [Array]$Values = $Out | ForEach-Object {\n # Split the output in name and description\n $Name, $Description = $_.Split(\"\\`t\", 2)\n __${camelCase(getAppBin(context))}_debug \"Name: $Name Description: $Description\"\n\n # Look for the longest completion so that we can format things nicely\n if ($Longest -lt $Name.Length) {\n $Longest = $Name.Length\n }\n\n # Set the description to a one space string if there is none set.\n # This is needed because the CompletionResult does not accept an empty string as argument\n if (-Not $Description) {\n $Description = \" \"\n }\n @{ Name = \"$Name\"; Description = \"$Description\" }\n }\n\n\n $Space = \" \"\n if (($Directive -band $ShellCompDirectiveNoSpace) -ne 0 ) {\n # remove the space here\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveNoSpace is called\"\n $Space = \"\"\n }\n\n if ((($Directive -band $ShellCompDirectiveFilterFileExt) -ne 0 ) -or\n (($Directive -band $ShellCompDirectiveFilterDirs) -ne 0 )) {\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveFilterFileExt ShellCompDirectiveFilterDirs are not supported\"\n\n # return here to prevent the completion of the extensions\n return\n }\n\n $Values = $Values | Where-Object {\n # filter the result\n $_.Name -like \"$WordToComplete*\"\n\n # Join the flag back if we have an equal sign flag\n if ( $IsEqualFlag ) {\n __${camelCase(getAppBin(context))}_debug \"Join the equal sign flag back to the completion value\"\n $_.Name = $Flag + \"=\" + $_.Name\n }\n }\n\n # we sort the values in ascending order by name if keep order isn't passed\n if (($Directive -band $ShellCompDirectiveKeepOrder) -eq 0 ) {\n $Values = $Values | Sort-Object -Property Name\n }\n\n if (($Directive -band $ShellCompDirectiveNoFileComp) -ne 0 ) {\n __${camelCase(getAppBin(context))}_debug \"ShellCompDirectiveNoFileComp is called\"\n\n if ($Values.Length -eq 0) {\n # Just print an empty string here so the\n # shell does not start to complete paths.\n # We cannot use CompletionResult here because\n # it does not accept an empty string as argument.\n \"\"\n return\n }\n }\n\n # Get the current mode\n $Mode = (Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq \"Tab\" }).Function\n __${camelCase(getAppBin(context))}_debug \"Mode: $Mode\"\n\n $Values | ForEach-Object {\n\n # store temporary because switch will overwrite $_\n $comp = $_\n\n # PowerShell supports three different completion modes\n # - TabCompleteNext (default windows style - on each key press the next option is displayed)\n # - Complete (works like bash)\n # - MenuComplete (works like zsh)\n # You set the mode with Set-PSReadLineKeyHandler -Key Tab -Function <mode>\n\n # CompletionResult Arguments:\n # 1) CompletionText text to be used as the auto completion result\n # 2) ListItemText text to be displayed in the suggestion list\n # 3) ResultType type of completion result\n # 4) ToolTip text for the tooltip with details about the object\n\n switch ($Mode) {\n\n # bash like\n \"Complete\" {\n\n if ($Values.Length -eq 1) {\n __${camelCase(\n getAppBin(context)\n )}_debug \"Only one completion left\"\n\n # insert space after value\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n\n } else {\n # Add the proper number of spaces to align the descriptions\n while($comp.Name.Length -lt $Longest) {\n $comp.Name = $comp.Name + \" \"\n }\n\n # Check for empty description and only add parentheses if needed\n if ($($comp.Description) -eq \" \" ) {\n $Description = \"\"\n } else {\n $Description = \" ($($comp.Description))\"\n }\n\n [System.Management.Automation.CompletionResult]::new(\"$($comp.Name)$Description\", \"$($comp.Name)$Description\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n # zsh like\n \"MenuComplete\" {\n # insert space after value\n # MenuComplete will automatically show the ToolTip of\n # the highlighted value at the bottom of the suggestions.\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars) + $Space, \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n\n # TabCompleteNext and in case we get something unknown\n Default {\n # Like MenuComplete but we don't want to add a space here because\n # the user need to press space anyway to get the completion.\n # Description will not be shown because that's not possible with TabCompleteNext\n [System.Management.Automation.CompletionResult]::new($($comp.Name | __${name}_escapeStringWithSpecialChars), \"$($comp.Name)\", 'ParameterValue', \"$($comp.Description)\")\n }\n }\n\n }\n}\n\nRegister-ArgumentCompleter -CommandName '${getAppBin(\n context\n )}' -ScriptBlock $__${camelCase(getAppBin(context))}CompleterBlock\n\\`); `}\n />\n <Spacing />\n <IfStatement condition={code`options.config`}>\n <VarDeclaration\n let\n name=\"configFilePath\"\n type=\"string\"\n initializer={code`options.config === true ? \"~/.config/powershell/Microsoft.PowerShell_profile.ps1\" : options.config`}\n />\n <Spacing />\n <IfStatement condition={code`configFilePath.startsWith(\"~\")`}>\n {code`configFilePath = join(os.homedir(), configFilePath.replace(\"~\", \"\")); `}\n </IfStatement>\n <Spacing />\n <VarDeclaration\n let\n name=\"configFileContent\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n {code`try {\n configFileContent = await readFile(configFilePath, \"utf8\");\n } catch (error) {\n if (error.code === \"ENOENT\") {\n // If the file doesn't exist, we can create it later when writing the completion script.\n warn(\\`Configuration file \\${colors.bold(configFilePath)} does not exist. It will be created when the completion script is written.\\`);\n } else {\n return { error };\n }\n }\n\n await writeFile(configFilePath, \\`\\${configFileContent}\\\\n\\\\n\\${stripAnsi(completions)}\\`);\n\n success(\\`${getAppTitle(context)} PowerShell completion script has been generated and appended to \\${colors.bold(configFilePath)}. Please restart your terminal or run \\`source \\${configFilePath}\\` to apply the changes.\\`); `}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`options.script`}>\n {code`const outputPath = options.script === true ? \"${getAppBin(context)}-completions.powershell\" : options.script;\n await writeFile(outputPath, stripAnsi(completions));\n\n success(\\`${getAppTitle(context)} PowerShell completion script has been generated at \\${colors.bold(outputPath)}.\\`);`}\n </IfStatement>\n <Spacing />\n <IfStatement condition={code`!options.config && !options.script`}>\n {code`writeLine(\" ------------------------------------------------- \");\n writeLine(completions);\n writeLine(\" ------------------------------------------------- \");`}\n </IfStatement>\n </FunctionDeclaration>\n </TypescriptFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,SAAS,+BAAsC;CAC/C,MAAQ,UAAU,eAAsB;AACxC,QAAS,gBAAkB,gBAAe;EAC1C,IAAQ,OAAC;AACH,UAAO,UAAU,QAAE,WAAiB,eAAQ,cAAA,aAAA;;EAElD,SAAa;;GAEX,oBAAA,CAAA,YAAA,YAAA;GACC;EACD,gBAAA,EACI,uBAAU;GAAA;GAAA;GAA+B;GAAA;GAAA;GAAA,EAC7C;;AAEA,UAAO;IAAA,gBAAA,OAAA,EACJ,SAAA,mDACC,CAAA;IAAI,gBAAW,sBAAA;KACb,UAAQ;KACR,MAAC;KACD,IAAC,WAAW;AACX,aAAQ;OAAA,gBAAE,OAAA;QACZ,SAAA;QACD,IAAS,WAAA;AACD,gBAAO,CAAA,gBAAI,cAAA,EACT,UAAU,qEACnB,CAAA,EAAA,gBAAA,mBAAA;UACD,IAAc,OAAE;AACP,kBAAM,eAAU;;UAEpB,IAAS,eAAC;AACH,kBAAC,GAAA,UAAA,QAAA,CAAA;;UAER,CAAA,CAAA;;QAEH,CAAA;OAAA,gBAAA,iBAAA;QACI,MAAC;QACN,UAAA;QACE,MAAM;QACJ,CAAA;OAAA,gBAAqB,SAAS,EAAC,CAAE;OAAC,gBAAiB,OAAM;QACzD,SAAA;QACC,IAAI,WAAE;AACN,gBAAA,CAAA,gBAA2B,cAAU,EACtC,UAAA,uNACI,CAAA,EAAA,gBAAA,mBAAA;UACN,IAAA,OAAgB;AACP,kBAAA,eAAA;;UAEP,cAAmB;UACnB,CAAA,CAAA;;QAEA,CAAC;OAAA,gBAAiB,iBAAkB;QACpC,MAAA;QACD,UAAK;QACN,MAAA;QACD,CAAA;OAAA;;KAED,CAAA;IAAA,gBAAe,SAAc,EAAG,CAAC;IAAA,gBAAkB,OAAA,EACnD,SAAA,+DACA,CAAC;IAAA,gBAAA,qBAAA;KACA,UAAA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QAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;wBAyBe,UAAA,UAAA,QAAA,CAAA,CAAA;;;4FAGuB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAuC9B,UAAA,QAAA,CAAA,oBAAA,UAAA,UAAA,QAAA,CAAA,CAAA;;;QAGR,CAAA;OAAA,gBAAA,SAAA,EAAA,CAAA;OAAA,gBAAA,aAAA;QACJ,WAAA,IAAA;;AAES,gBAAA;UAAA,gBAA+B,gBAAY;WACxC,OAAA;WACG,MAAA;WACT,MAAA;WACG,aAAA,IAAA;WACA,CAAO;UAAE,gBAAA,SAAA,EAAA,CAAA;UAAA,gBAAA,aAAA;WACT,WAAY,IAAU;WACpB,UAAA,IAAA;WACC,CAAA;UAAA,gBAAA,SAAA,EAAA,CAAA;UAAA,gBAAA,gBAAA;WACI,OAAE;WACF,MAAE;WACN,MAAA;WACD,aAAA,IAAA;WACA,CAAA;UAAO,gBAAE,SAAA,EAAA,CAAA;UAAA,WAAA,IAAA;;;;;;;;;;;;;sBAaR,YAAoB,QAAM,CAAA,gMAAgC;UAAA;;QAE3D,CAAC;OAAE,gBAAkB,SAAS,EAAA,CAAA;OAAA,gBAAA,aAAA;QAC7B,WAAW,IAAC;QACZ,IAAE,WAAO;AACP,gBAAK,IAAA,iDAAA,UAAA,QAAA,CAAA;;;sBAGT,YAAA,QAAA,CAAA;;QAEA,CAAA;OAAA,gBAAgB,SAAe,EAAE,CAAC;OAAE,gBAAkB,aAAU;;QAEhE,UAAY,IAAA;;;QAGb,CAAA;OAAA;;KAEF,CAAC;IAAC;;EAEN,CAAC"}
@@ -1,26 +1,27 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_helpers_complete_command = require('../helpers/complete-command.cjs');
2
3
  const require_helpers_completion_directive_constants = require('../helpers/completion-directive-constants.cjs');
3
- let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
- let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
5
- let __stryke_path = require("@stryke/path");
6
- let __alloy_js_core = require("@alloy-js/core");
7
- let __alloy_js_typescript = require("@alloy-js/typescript");
8
- let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
9
- let __powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
10
- let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
11
- let __powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
12
- let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
13
- let __stryke_string_format = require("@stryke/string-format");
4
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
6
+ let _stryke_path = require("@stryke/path");
7
+ let _alloy_js_core = require("@alloy-js/core");
8
+ let _alloy_js_typescript = require("@alloy-js/typescript");
9
+ let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
+ let _powerlines_plugin_alloy_core = require("@powerlines/plugin-alloy/core");
11
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
12
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
13
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
14
+ let _stryke_string_format = require("@stryke/string-format");
14
15
 
15
16
  //#region src/components/zsh-command.tsx
16
17
  /**
17
18
  * The Zsh Completions commands' handler wrapper for the Shell Shock project.
18
19
  */
19
20
  function ZshCompletionsCommand() {
20
- const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
21
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.TypescriptFile, {
21
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
22
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
22
23
  get path() {
23
- return (0, __stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "command.ts");
24
+ return (0, _stryke_path.joinPaths)(context.entryPath, "completions", "zsh", "command.ts");
24
25
  },
25
26
  imports: {
26
27
  "node:os": ["os"],
@@ -35,43 +36,43 @@ function ZshCompletionsCommand() {
35
36
  ] },
36
37
  get children() {
37
38
  return [
38
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh completions command." }),
39
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
39
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Options for the Zsh completions command." }),
40
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
40
41
  "export": true,
41
42
  name: "ZshCompletionsOptions",
42
43
  get children() {
43
44
  return [
44
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
45
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
45
46
  heading: "The path to write the completion script to.",
46
47
  get children() {
47
- return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.zsh\` extension will be used.` }), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
48
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `If no extension is provided, the \`.zsh\` extension will be used.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
48
49
  get type() {
49
- return __powerlines_deepkit_vendor_type.ReflectionKind.string;
50
+ return _powerlines_deepkit_vendor_type.ReflectionKind.string;
50
51
  },
51
52
  get defaultValue() {
52
- return `${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh`;
53
+ return `${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh`;
53
54
  }
54
55
  })];
55
56
  }
56
57
  }),
57
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
58
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
58
59
  name: "script",
59
60
  optional: true,
60
61
  type: "string | true"
61
62
  }),
62
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
63
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
63
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
64
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
64
65
  heading: "The Zsh configuration file to append the completion script to.",
65
66
  get children() {
66
- return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the Zsh configuration file include: \\n- \`~/.zshrc\` \\n- \`~/.zprofile\`` }), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
67
+ return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The generated completion script will be appended to the specified configuration file. Possible values for the Zsh configuration file include: \\n- \`~/.zshrc\` \\n- \`~/.zprofile\`` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
67
68
  get type() {
68
- return __powerlines_deepkit_vendor_type.ReflectionKind.string;
69
+ return _powerlines_deepkit_vendor_type.ReflectionKind.string;
69
70
  },
70
71
  defaultValue: "~/.zshrc"
71
72
  })];
72
73
  }
73
74
  }),
74
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.InterfaceMember, {
75
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.InterfaceMember, {
75
76
  name: "config",
76
77
  optional: true,
77
78
  type: "string | true"
@@ -79,9 +80,9 @@ function ZshCompletionsCommand() {
79
80
  ];
80
81
  }
81
82
  }),
82
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
83
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh\\` command." }),
84
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
83
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
84
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "Handler logic for the \\`completions zsh\\` command." }),
85
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
85
86
  "export": true,
86
87
  "default": true,
87
88
  async: true,
@@ -92,24 +93,24 @@ function ZshCompletionsCommand() {
92
93
  }],
93
94
  get children() {
94
95
  return [
95
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
96
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
96
97
  "const": true,
97
98
  name: "completions",
98
99
  type: "string",
99
100
  get initializer() {
100
- return __alloy_js_core.code`#compdef ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
101
- compdef _${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))} ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}
101
+ return _alloy_js_core.code`#compdef ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}
102
+ compdef _${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))} ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}
102
103
 
103
- # zsh completion for ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
104
+ # zsh completion for ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} -*- shell-script -*-
104
105
 
105
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug() {
106
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug() {
106
107
  local file="$BASH_COMP_DEBUG_FILE"
107
108
  if [[ -n \${file} ]]; then
108
109
  echo "$*" >> "\${file}"
109
110
  fi
110
111
  }
111
112
 
112
- _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
113
+ _${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}() {
113
114
  local shellCompDirectiveError=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveError}
114
115
  local shellCompDirectiveNoSpace=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoSpace}
115
116
  local shellCompDirectiveNoFileComp=${require_helpers_completion_directive_constants.CompletionDirective.CompletionDirectiveNoFileComp}
@@ -120,20 +121,20 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
120
121
  local lastParam lastChar flagPrefix requestComp out directive comp lastComp noSpace keepOrder
121
122
  local -a completions
122
123
 
123
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "\\n========= starting completion logic =========="
124
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
124
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "\\n========= starting completion logic =========="
125
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "CURRENT: \${CURRENT}, words[*]: \${words[*]}"
125
126
 
126
127
  # The user could have moved the cursor backwards on the command-line.
127
128
  # We need to trigger completion from the $CURRENT location, so we need
128
129
  # to truncate the command-line ($words) up to the $CURRENT location.
129
130
  # (We cannot use $CURSOR as its value does not work when a command is an alias.)
130
131
  words=( "\${=words[1,CURRENT]}" )
131
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Truncated words[*]: \${words[*]},"
132
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Truncated words[*]: \${words[*]},"
132
133
 
133
134
  lastParam=\${words[-1]}
134
135
  lastChar=\${lastParam[-1]}
135
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
136
- # For zsh, when completing a flag with an = (e.g., ${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} -n=<TAB>)
136
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "lastParam: \${lastParam}, lastChar: \${lastChar}"
137
+ # For zsh, when completing a flag with an = (e.g., ${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} -n=<TAB>)
137
138
  # completions must be prefixed with the flag
138
139
  setopt local_options BASH_REMATCH
139
140
  if [[ "\${lastParam}" =~ '-.*=' ]]; then
@@ -146,7 +147,7 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
146
147
  if [ "\${lastChar}" = "" ]; then
147
148
  # If the last parameter is complete (there is a space following it)
148
149
  # We add an extra empty parameter so we can indicate this to the go completion code.
149
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding extra empty parameter"
150
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding extra empty parameter"
150
151
  args_to_quote+=("")
151
152
  fi
152
153
 
@@ -156,18 +157,18 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
156
157
  # Join the main command and the quoted arguments into a single string for eval
157
158
  requestComp="${require_helpers_complete_command.exec} complete -- \${quoted_args[*]}"
158
159
 
159
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "About to call: eval \${requestComp}"
160
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "About to call: eval \${requestComp}"
160
161
 
161
162
  # Use eval to handle any environment variables and such
162
163
  out=$(eval \${requestComp} 2>/dev/null)
163
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completion output: \${out}"
164
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completion output: \${out}"
164
165
 
165
166
  # Extract the directive integer following a : from the last line
166
167
  local lastLine
167
168
  while IFS='\n' read -r line; do
168
169
  lastLine=\${line}
169
170
  done < <(printf "%s\n" "\${out[@]}")
170
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "last line: \${lastLine}"
171
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "last line: \${lastLine}"
171
172
 
172
173
  if [ "\${lastLine[1]}" = : ]; then
173
174
  directive=\${lastLine[2,-1]}
@@ -177,16 +178,16 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
177
178
  out=\${out[1,-$suffix]}
178
179
  else
179
180
  # There is no directive specified. Leave $out as is.
180
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No directive found. Setting to default"
181
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "No directive found. Setting to default"
181
182
  directive=0
182
183
  fi
183
184
 
184
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "directive: \${directive}"
185
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completions: \${out}"
186
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "flagPrefix: \${flagPrefix}"
185
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "directive: \${directive}"
186
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "completions: \${out}"
187
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "flagPrefix: \${flagPrefix}"
187
188
 
188
189
  if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
189
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completion received error. Ignoring completions."
190
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Completion received error. Ignoring completions."
190
191
  return
191
192
  fi
192
193
 
@@ -197,11 +198,11 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
197
198
  while IFS='\n' read -r comp; do
198
199
  # Check if this is an activeHelp statement (i.e., prefixed with $activeHelpMarker)
199
200
  if [ "\${comp[1,$endIndex]}" = "$activeHelpMarker" ];then
200
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp found: $comp"
201
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp found: $comp"
201
202
  comp="\${comp[$startIndex,-1]}"
202
203
  if [ -n "$comp" ]; then
203
204
  compadd -x "\${comp}"
204
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp will need delimiter"
205
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "ActiveHelp will need delimiter"
205
206
  hasActiveHelp=1
206
207
  fi
207
208
  continue
@@ -217,7 +218,7 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
217
218
  local tab="$(printf '\\t')"
218
219
  comp=\${comp//$tab/:}
219
220
 
220
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding completion: \${comp}"
221
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding completion: \${comp}"
221
222
  completions+=\${comp}
222
223
  lastComp=$comp
223
224
  fi
@@ -228,19 +229,19 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
228
229
  # - file completion will be performed (so there will be choices after the activeHelp)
229
230
  if [ $hasActiveHelp -eq 1 ]; then
230
231
  if [ \${#completions} -ne 0 ] || [ $((directive & shellCompDirectiveNoFileComp)) -eq 0 ]; then
231
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding activeHelp delimiter"
232
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Adding activeHelp delimiter"
232
233
  compadd -x "--"
233
234
  hasActiveHelp=0
234
235
  fi
235
236
  fi
236
237
 
237
238
  if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
238
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating nospace."
239
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating nospace."
239
240
  noSpace="-S ''"
240
241
  fi
241
242
 
242
243
  if [ $((directive & shellCompDirectiveKeepOrder)) -ne 0 ]; then
243
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating keep order."
244
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating keep order."
244
245
  keepOrder="-V"
245
246
  fi
246
247
 
@@ -257,17 +258,17 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
257
258
  done
258
259
  filteringCmd+=" \${flagPrefix}"
259
260
 
260
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "File filtering command: $filteringCmd"
261
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "File filtering command: $filteringCmd"
261
262
  _arguments '*:filename:'"$filteringCmd"
262
263
  elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
263
264
  # File completion for directories only
264
265
  local subdir
265
266
  subdir="\${completions[1]}"
266
267
  if [ -n "$subdir" ]; then
267
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in $subdir"
268
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in $subdir"
268
269
  pushd "\${subdir}" >/dev/null 2>&1
269
270
  else
270
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in ."
271
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Listing directories in ."
271
272
  fi
272
273
 
273
274
  local result
@@ -278,17 +279,17 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
278
279
  fi
279
280
  return $result
280
281
  else
281
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Calling _describe"
282
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Calling _describe"
282
283
  if eval _describe $keepOrder "completions" completions -Q \${flagPrefix} \${noSpace}; then
283
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe found some completions"
284
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe found some completions"
284
285
 
285
286
  # Return the success of having called _describe
286
287
  return 0
287
288
  else
288
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe did not find completions."
289
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Checking if we should do file completion."
289
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "_describe did not find completions."
290
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Checking if we should do file completion."
290
291
  if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
291
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "deactivating file completion"
292
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "deactivating file completion"
292
293
 
293
294
  # Return 0 to indicate completion is finished and prevent zsh from
294
295
  # trying other completion algorithms (which could cause hanging).
@@ -296,7 +297,7 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
296
297
  return 0
297
298
  else
298
299
  # Perform file completion
299
- __${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating file completion"
300
+ __${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}_debug "Activating file completion"
300
301
 
301
302
  # We must return the result of this command, so it must be the
302
303
  # last command, or else we must store its result to return it.
@@ -307,37 +308,37 @@ _${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}() {
307
308
  }
308
309
 
309
310
  # don't run the completion function when being sourced or eval-ed
310
- if [ "\${funcstack[1]}" = "_${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}" ]; then
311
- _${(0, __stryke_string_format.snakeCase)((0, __shell_shock_core_plugin_utils.getAppBin)(context))}
311
+ if [ "\${funcstack[1]}" = "_${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}" ]; then
312
+ _${(0, _stryke_string_format.snakeCase)((0, _shell_shock_core_plugin_utils.getAppBin)(context))}
312
313
  fi
313
314
  \`);`;
314
315
  }
315
316
  }),
316
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
317
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
318
- condition: __alloy_js_core.code`options.config`,
317
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
318
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
319
+ condition: _alloy_js_core.code`options.config`,
319
320
  get children() {
320
321
  return [
321
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
322
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
322
323
  "let": true,
323
324
  name: "configFilePath",
324
325
  type: "string",
325
- initializer: __alloy_js_core.code`options.config === true ? "~/.zshrc" : options.config`
326
+ initializer: _alloy_js_core.code`options.config === true ? "~/.zshrc" : options.config`
326
327
  }),
327
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
328
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
329
- condition: __alloy_js_core.code`configFilePath.startsWith("~")`,
330
- children: __alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
328
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
329
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
330
+ condition: _alloy_js_core.code`configFilePath.startsWith("~")`,
331
+ children: _alloy_js_core.code`configFilePath = join(os.homedir(), configFilePath.replace("~", "")); `
331
332
  }),
332
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
333
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
333
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
334
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
334
335
  "let": true,
335
336
  name: "configFileContent",
336
337
  type: "string",
337
- initializer: __alloy_js_core.code`"";`
338
+ initializer: _alloy_js_core.code`"";`
338
339
  }),
339
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
340
- (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`try {
340
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
341
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`try {
341
342
  configFileContent = await readFile(configFilePath, "utf8");
342
343
  } catch (error) {
343
344
  if (error.code === "ENOENT") {
@@ -350,24 +351,24 @@ fi
350
351
 
351
352
  await writeFile(configFilePath, \`\${configFileContent}\\n\\n\${stripAnsi(completions)}\`);
352
353
 
353
- success(\`${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
354
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated and appended to \${colors.bold(configFilePath)}. Please restart your terminal or run \`source \${configFilePath}\` to apply the changes.\`); `)
354
355
  ];
355
356
  }
356
357
  }),
357
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
358
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
359
- condition: __alloy_js_core.code`options.script`,
358
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
359
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
360
+ condition: _alloy_js_core.code`options.script`,
360
361
  get children() {
361
- return __alloy_js_core.code`const outputPath = options.script === true ? "${(0, __shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh" : options.script;
362
+ return _alloy_js_core.code`const outputPath = options.script === true ? "${(0, _shell_shock_core_plugin_utils.getAppBin)(context)}-completions.zsh" : options.script;
362
363
  await writeFile(outputPath, stripAnsi(completions));
363
364
 
364
- success(\`${(0, __shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated at \${colors.bold(outputPath)}.\`);`;
365
+ success(\`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} Zsh completion script has been generated at \${colors.bold(outputPath)}.\`);`;
365
366
  }
366
367
  }),
367
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core.Spacing, {}),
368
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
369
- condition: __alloy_js_core.code`!options.config && !options.script`,
370
- children: __alloy_js_core.code`writeLine(" ------------------------------------------------- ");
368
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core.Spacing, {}),
369
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
370
+ condition: _alloy_js_core.code`!options.config && !options.script`,
371
+ children: _alloy_js_core.code`writeLine(" ------------------------------------------------- ");
371
372
  writeLine(completions);
372
373
  writeLine(" ------------------------------------------------- ");`
373
374
  })
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-command.d.cts","names":[],"sources":["../../src/components/zsh-command.tsx"],"sourcesContent":[],"mappings":";;;;;;AA+CgB,iBAAA,qBAAA,CAAA,CAAqB,EAAA,eAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"zsh-command.d.cts","names":[],"sources":["../../src/components/zsh-command.tsx"],"mappings":";;;;;;iBA+CgB,qBAAA,CAAA,GAAqB,eAAA,CAAA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-command.d.mts","names":[],"sources":["../../src/components/zsh-command.tsx"],"sourcesContent":[],"mappings":";;;;;;AA+CgB,iBAAA,qBAAA,CAAA,CAAqB,EAAA,eAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"zsh-command.d.mts","names":[],"sources":["../../src/components/zsh-command.tsx"],"mappings":";;;;;;iBA+CgB,qBAAA,CAAA,GAAqB,eAAA,CAAA,QAAA"}