@oclif/plugin-autocomplete
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -0,1 +1,14 @@ | ||
# [0.3.0](https://github.com/oclif/plugin-autocomplete/compare/v0.2.1...v0.3.0) (2020-12-17) | ||
### Bug Fixes | ||
* completion for subcommands ([#126](https://github.com/oclif/plugin-autocomplete/issues/126)) ([30b2857](https://github.com/oclif/plugin-autocomplete/commit/30b2857ed5f0ee9557d150e9ac75038f012c8964)), closes [oclif#9](https://github.com/oclif/issues/9) | ||
* **zsh:** update zsh autocomplete to work with default settings ([#92](https://github.com/oclif/plugin-autocomplete/issues/92)) ([b9e8e7b](https://github.com/oclif/plugin-autocomplete/commit/b9e8e7ba2946c5b16d8af32b70cfffa062880572)), closes [#91](https://github.com/oclif/plugin-autocomplete/issues/91) | ||
### Features | ||
* install on windows bash ([#34](https://github.com/oclif/plugin-autocomplete/issues/34)) ([4ca20e5](https://github.com/oclif/plugin-autocomplete/commit/4ca20e5f840c715fe658f0a12840e34783793995)) | ||
## [0.2.1](https://github.com/oclif/plugin-autocomplete/compare/v0.2.0...v0.2.1) (2020-12-11) | ||
@@ -2,0 +15,0 @@ |
@@ -5,2 +5,3 @@ import Command from '@oclif/command'; | ||
get cliBinEnvVar(): string; | ||
determineShell(shell: string): string; | ||
errorIfWindows(): void; | ||
@@ -11,2 +12,3 @@ errorIfNotSupportedShell(shell: string): void; | ||
writeLogFile(msg: string): void; | ||
private isBashOnWindows; | ||
} |
@@ -14,4 +14,15 @@ "use strict"; | ||
} | ||
determineShell(shell) { | ||
if (!shell) { | ||
this.error('Missing required argument shell'); | ||
} | ||
else if (this.isBashOnWindows(shell)) { | ||
return 'bash'; | ||
} | ||
else { | ||
return shell; | ||
} | ||
} | ||
errorIfWindows() { | ||
if (this.config.windows) { | ||
if (this.config.windows && !this.isBashOnWindows(this.config.shell)) { | ||
throw new Error('Autocomplete is not currently supported in Windows'); | ||
@@ -40,3 +51,6 @@ } | ||
} | ||
isBashOnWindows(shell) { | ||
return shell.endsWith('\\bash.exe'); | ||
} | ||
} | ||
exports.AutocompleteBase = AutocompleteBase; |
@@ -157,25 +157,2 @@ "use strict"; | ||
if ! type __ltrim_colon_completions >/dev/null 2>&1; then | ||
# Copyright © 2006-2008, Ian Macdonald <ian@caliban.org> | ||
# © 2009-2017, Bash Completion Maintainers | ||
__ltrim_colon_completions() { | ||
# If word-to-complete contains a colon, | ||
# and bash-version < 4, | ||
# or bash-version >= 4 and COMP_WORDBREAKS contains a colon | ||
if [[ | ||
"$1" == *:* && ( | ||
\${BASH_VERSINFO[0]} -lt 4 || | ||
(\${BASH_VERSINFO[0]} -ge 4 && "$COMP_WORDBREAKS" == *:*) | ||
) | ||
]]; then | ||
# Remove colon-word prefix from COMPREPLY items | ||
local colon_word=\${1%\${1##*:}} | ||
local i=\${#COMPREPLY[*]} | ||
while [ $((--i)) -ge 0 ]; do | ||
COMPREPLY[$i]=\${COMPREPLY[$i]#"$colon_word"} | ||
done | ||
fi | ||
} | ||
fi | ||
_${cliBin}() | ||
@@ -191,13 +168,20 @@ { | ||
if [[ "\${COMP_CWORD}" -eq 1 ]] ; then | ||
opts=$(printf "$commands" | grep -Eo '^[a-zA-Z0-9:_-]+') | ||
COMPREPLY=( $(compgen -W "\${opts}" -- \${cur}) ) | ||
__ltrim_colon_completions "$cur" | ||
if [[ "$cur" != "-"* ]]; then | ||
opts=$(printf "$commands" | grep -Eo '^[a-zA-Z0-9:_-]+') | ||
else | ||
if [[ $cur == "-"* ]] ; then | ||
opts=$(printf "$commands" | grep "\${COMP_WORDS[1]}" | sed -n "s/^\${COMP_WORDS[1]} //p") | ||
COMPREPLY=( $(compgen -W "\${opts}" -- \${cur}) ) | ||
fi | ||
local __COMP_WORDS | ||
if [[ \${COMP_WORDS[2]} == ":" ]]; then | ||
#subcommand | ||
__COMP_WORDS=$(printf "%s" "\${COMP_WORDS[@]:1:3}") | ||
else | ||
#simple command | ||
__COMP_WORDS="\${COMP_WORDS[@]:1:1}" | ||
fi | ||
opts=$(printf "$commands" | grep "\${__COMP_WORDS}" | sed -n "s/^\${__COMP_WORDS} //p") | ||
fi | ||
_get_comp_words_by_ref -n : cur | ||
COMPREPLY=( $(compgen -W "\${opts}" -- \${cur}) ) | ||
__ltrim_colon_completions "$cur" | ||
return 0 | ||
} | ||
@@ -204,0 +188,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const command_1 = require("@oclif/command"); | ||
const chalk_1 = require("chalk"); | ||
const chalk = require("chalk"); | ||
const cli_ux_1 = require("cli-ux"); | ||
@@ -11,5 +11,5 @@ const base_1 = require("../../base"); | ||
const { args, flags } = this.parse(Index); | ||
const shell = args.shell || this.config.shell; | ||
const shell = args.shell || this.determineShell(this.config.shell); | ||
this.errorIfNotSupportedShell(shell); | ||
cli_ux_1.cli.action.start(`${chalk_1.default.bold('Building the autocomplete cache')}`); | ||
cli_ux_1.cli.action.start(`${chalk.bold('Building the autocomplete cache')}`); | ||
await create_1.default.run([], this.config); | ||
@@ -20,8 +20,8 @@ cli_ux_1.cli.action.stop(); | ||
const tabStr = shell === 'bash' ? '<TAB><TAB>' : '<TAB>'; | ||
const note = shell === 'zsh' ? `After sourcing, you can run \`${chalk_1.default.cyan('$ compaudit -D')}\` to ensure no permissions conflicts are present` : 'If your terminal starts as a login shell you may need to print the init script into ~/.bash_profile or ~/.profile.'; | ||
const note = shell === 'zsh' ? `After sourcing, you can run \`${chalk.cyan('$ compaudit -D')}\` to ensure no permissions conflicts are present` : 'If your terminal starts as a login shell you may need to print the init script into ~/.bash_profile or ~/.profile.'; | ||
this.log(` | ||
${chalk_1.default.bold(`Setup Instructions for ${bin.toUpperCase()} CLI Autocomplete ---`)} | ||
${chalk.bold(`Setup Instructions for ${bin.toUpperCase()} CLI Autocomplete ---`)} | ||
1) Add the autocomplete env var to your ${shell} profile and source it | ||
${chalk_1.default.cyan(`$ printf "$(${bin} autocomplete:script ${shell})" >> ~/.${shell}rc; source ~/.${shell}rc`)} | ||
${chalk.cyan(`$ printf "eval $(${bin} autocomplete:script ${shell})" >> ~/.${shell}rc; source ~/.${shell}rc`)} | ||
@@ -31,4 +31,4 @@ NOTE: ${note} | ||
2) Test it out, e.g.: | ||
${chalk_1.default.cyan(`$ ${bin} ${tabStr}`)} # Command completion | ||
${chalk_1.default.cyan(`$ ${bin} command --${tabStr}`)} # Flag completion | ||
${chalk.cyan(`$ ${bin} ${tabStr}`)} # Command completion | ||
${chalk.cyan(`$ ${bin} command --${tabStr}`)} # Flag completion | ||
@@ -35,0 +35,0 @@ Enjoy! |
@@ -12,2 +12,3 @@ import { AutocompleteBase } from '../../base'; | ||
private get prefix(); | ||
private get suffix(); | ||
} |
@@ -12,7 +12,10 @@ "use strict"; | ||
const shellUpcase = shell.toUpperCase(); | ||
this.log(`${this.prefix}${binUpcase}_AC_${shellUpcase}_SETUP_PATH=${path.join(this.autocompleteCacheDir, `${shell}_setup`)} && test -f $${binUpcase}_AC_${shellUpcase}_SETUP_PATH && source $${binUpcase}_AC_${shellUpcase}_SETUP_PATH;`); | ||
this.log(`${this.prefix}${binUpcase}_AC_${shellUpcase}_SETUP_PATH=${path.join(this.autocompleteCacheDir, `${shell}_setup`)} && test -f $${binUpcase}_AC_${shellUpcase}_SETUP_PATH && source $${binUpcase}_AC_${shellUpcase}_SETUP_PATH;${this.suffix}`); | ||
} | ||
get prefix() { | ||
return `\n# ${this.cliBin} autocomplete setup\n`; | ||
return '\n'; | ||
} | ||
get suffix() { | ||
return ` # ${this.cliBin} autocomplete setup\n`; | ||
} | ||
} | ||
@@ -19,0 +22,0 @@ exports.default = Script; |
@@ -1,1 +0,1 @@ | ||
{"version":"0.2.1","commands":{"autocomplete:create":{"id":"autocomplete:create","description":"create autocomplete setup scripts and completion functions","pluginName":"@oclif/plugin-autocomplete","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"autocomplete":{"id":"autocomplete","description":"display autocomplete installation instructions","pluginName":"@oclif/plugin-autocomplete","pluginType":"core","aliases":[],"examples":["$ <%= config.bin %> autocomplete","$ <%= config.bin %> autocomplete bash","$ <%= config.bin %> autocomplete zsh","$ <%= config.bin %> autocomplete --refresh-cache"],"flags":{"refresh-cache":{"name":"refresh-cache","type":"boolean","char":"r","description":"Refresh cache (ignores displaying instructions)","allowNo":false}},"args":[{"name":"shell","description":"shell type","required":false}]},"autocomplete:script":{"id":"autocomplete:script","description":"outputs autocomplete config script for shells","pluginName":"@oclif/plugin-autocomplete","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[{"name":"shell","description":"shell type","required":false}]}}} | ||
{"version":"0.3.0","commands":{"autocomplete:create":{"id":"autocomplete:create","description":"create autocomplete setup scripts and completion functions","pluginName":"@oclif/plugin-autocomplete","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[]},"autocomplete":{"id":"autocomplete","description":"display autocomplete installation instructions","pluginName":"@oclif/plugin-autocomplete","pluginType":"core","aliases":[],"examples":["$ <%= config.bin %> autocomplete","$ <%= config.bin %> autocomplete bash","$ <%= config.bin %> autocomplete zsh","$ <%= config.bin %> autocomplete --refresh-cache"],"flags":{"refresh-cache":{"name":"refresh-cache","type":"boolean","char":"r","description":"Refresh cache (ignores displaying instructions)","allowNo":false}},"args":[{"name":"shell","description":"shell type","required":false}]},"autocomplete:script":{"id":"autocomplete:script","description":"outputs autocomplete config script for shells","pluginName":"@oclif/plugin-autocomplete","pluginType":"core","hidden":true,"aliases":[],"flags":{},"args":[{"name":"shell","description":"shell type","required":false}]}}} |
{ | ||
"name": "@oclif/plugin-autocomplete", | ||
"description": "autocomplete plugin for oclif", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "Philipe Navarro @RasPhilCo", | ||
@@ -10,3 +10,3 @@ "bugs": "https://github.com/oclif/plugin-autocomplete/issues", | ||
"@oclif/config": "^1.13.0", | ||
"chalk": "^2.4.1", | ||
"chalk": "^4.1.0", | ||
"cli-ux": "^5.2.1", | ||
@@ -13,0 +13,0 @@ "debug": "^4.0.0", |
@@ -44,3 +44,3 @@ @oclif/plugin-autocomplete | ||
_See code: [src/commands/autocomplete/index.ts](https://github.com/oclif/plugin-autocomplete/blob/v0.2.1/src/commands/autocomplete/index.ts)_ | ||
_See code: [src/commands/autocomplete/index.ts](https://github.com/oclif/plugin-autocomplete/blob/v0.3.0/src/commands/autocomplete/index.ts)_ | ||
<!-- commandsstop --> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21644
413
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
Updatedchalk@^4.1.0