[READ-ONLY] Mirror of https://github.com/bombshell-dev/tab. shell autocompletions for javascript CLIs
4

Configure Feed

Select the types of activity you want to include in your feed.

fix: update `demo-cli-cac` to use the new API (#102)

authored by

AmirHossein Sakhravi and committed by
GitHub
(Jan 24, 2026, 1:32 PM +0330) 00161796 23a6ef9e

+23 -19
+23 -19
examples/demo-cli-cac/demo-cli-cac.js
··· 37 37 // custom config for options 38 38 for (const command of completion.commands.values()) { 39 39 for (const [optionName, config] of command.options.entries()) { 40 - if (optionName === '--port') { 41 - config.handler = () => { 42 - return [ 43 - { value: '3000', description: 'Default port' }, 44 - { value: '8080', description: 'Alternative port' }, 45 - ]; 40 + if (optionName === 'port') { 41 + config.handler = function (complete) { 42 + complete('3000', 'Default port'); 43 + complete('8080', 'Alternative port'); 46 44 }; 47 45 } 48 46 49 - if (optionName === '--mode') { 50 - config.handler = () => { 51 - return [ 52 - { value: 'development', description: 'Development mode' }, 53 - { value: 'production', description: 'Production mode' }, 54 - { value: 'test', description: 'Test mode' }, 55 - ]; 47 + if (optionName === 'mode') { 48 + config.handler = function (complete) { 49 + complete('development', 'Development mode'); 50 + complete('production', 'Production mode'); 51 + complete('test', 'Test mode'); 56 52 }; 57 53 } 58 54 59 - if (optionName === '--config') { 60 - config.handler = () => { 61 - return [ 62 - { value: 'config.json', description: 'JSON config file' }, 63 - { value: 'config.js', description: 'JavaScript config file' }, 64 - ]; 55 + if (optionName === 'config') { 56 + config.handler = function (complete) { 57 + complete('config.json', 'JSON config file'); 58 + complete('config.js', 'JavaScript config file'); 65 59 }; 66 60 } 61 + } 62 + } 63 + 64 + // for root command options 65 + for (const [optionName, config] of completion.options.entries()) { 66 + if (optionName === 'config') { 67 + config.handler = function (complete) { 68 + complete('config.json', 'JSON config file'); 69 + complete('config.js', 'JavaScript config file'); 70 + }; 67 71 } 68 72 } 69 73