(commands: string[])
| 20 | } |
| 21 | |
| 22 | function generateBashCompletion(commands: string[]): string { |
| 23 | const blockTypes = FILTERABLE_BLOCK_TYPES.join(' ') |
| 24 | |
| 25 | return `# Bash completion for deepnote CLI |
| 26 | # Add this to ~/.bashrc or ~/.bash_profile |
| 27 | |
| 28 | _deepnote_completions() { |
| 29 | local cur prev commands subcommand word |
| 30 | COMPREPLY=() |
| 31 | cur="\${COMP_WORDS[COMP_CWORD]}" |
| 32 | prev="\${COMP_WORDS[COMP_CWORD-1]}" |
| 33 | commands="${commands.join(' ')} help" |
| 34 | |
| 35 | # Find the subcommand by scanning COMP_WORDS |
| 36 | subcommand="" |
| 37 | for word in "\${COMP_WORDS[@]:1}"; do |
| 38 | case "\${word}" in |
| 39 | inspect|cat|run|open|validate|convert|split|completion|help|dag|stats|analyze|lint|show|vars|downstream|diff|integrations|pull) |
| 40 | subcommand="\${word}" |
| 41 | break |
| 42 | ;; |
| 43 | esac |
| 44 | done |
| 45 | |
| 46 | # Handle -o/--output option completion based on the subcommand |
| 47 | if [[ "\${prev}" == "-o" || "\${prev}" == "--output" ]]; then |
| 48 | case "\${subcommand}" in |
| 49 | inspect|run|analyze) |
| 50 | COMPREPLY=( $(compgen -W "json toon llm" -- "\${cur}") ) |
| 51 | return 0 |
| 52 | ;; |
| 53 | cat|open|validate|stats|lint|diff) |
| 54 | COMPREPLY=( $(compgen -W "json llm" -- "\${cur}") ) |
| 55 | return 0 |
| 56 | ;; |
| 57 | show) |
| 58 | COMPREPLY=( $(compgen -W "json dot llm" -- "\${cur}") ) |
| 59 | return 0 |
| 60 | ;; |
| 61 | vars|downstream) |
| 62 | COMPREPLY=( $(compgen -W "json llm" -- "\${cur}") ) |
| 63 | return 0 |
| 64 | ;; |
| 65 | split) |
| 66 | COMPREPLY=( $(compgen -d -- "\${cur}") ) |
| 67 | return 0 |
| 68 | ;; |
| 69 | esac |
| 70 | fi |
| 71 | |
| 72 | # Handle --type option completion for cat command |
| 73 | if [[ "\${prev}" == "--type" ]]; then |
| 74 | if [[ "\${subcommand}" == "cat" ]]; then |
| 75 | COMPREPLY=( $(compgen -W "${blockTypes}" -- "\${cur}") ) |
| 76 | return 0 |
| 77 | fi |
| 78 | fi |
| 79 |
no outgoing calls
no test coverage detected