webpack-cli
webpack-cli copied to clipboard
Feature:- AUTO TAB completion of flags
Is your feature request related to a problem? Please describe. when you type some cli flags and press TAB key. It doesn't autocomplete the flags. It should complete the flags automatically as per user input.
Describe the solution you'd like
I want the flags to autocomplete when i type some partial text of a flag just like in node REPL mode. Describe alternatives you've considered
Additional context
Not sure it is possible, because completion is scope of bash/terminal
something like this may possible - omelette
I am trying to implement this with yargs completion
I am trying to implement this with yargs completion
We are moving away from yargs https://github.com/webpack/webpack-cli/pull/1347, don't
@anshumanv any suggestions other than omelette
tabtab is another option.
We can't have it unless we move to new arg parser and start using flags from webpack core.
This issue had no activity for at least half a year.
It's subject to automatic issue closing if there is no activity in the next 15 days.
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
This issue had no activity for at least half a year.
It's subject to automatic issue closing if there is no activity in the next 15 days.
bump
This issue had no activity for at least half a year.
It's subject to automatic issue closing if there is no activity in the next 15 days.
bump
This issue had no activity for at least half a year.
It's subject to automatic issue closing if there is no activity in the next 15 days.
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
@snitin315 can I work on this issue or this issue is close due to inactivity ?
@aialok feel free to work on it.
Hello @snitin315 sir , I have some doubt regarding webpack. Is there any slack/discord channel where I can ask my doubts ? Webpack is going to participate for GSOC 2024 or not ? and I really really want to work with webpack. Can you please guide me how to get started with this ?
@aialok https://github.com/webpack/webpack/discussions/17441
Relative: https://github.com/tj/commander.js/issues/385#issuecomment-1457773417
Is the use of omelette good enough or tabtab be used?
@alexander-akait what can be the best way to get all the flags that are built in webpack-cli, according to you.
You can get them using commander API
Expanding on the API which is available, some deeper detail.
A Command
object has an options
property which is an array of the options. There are two complications you might care about when looking for completions:
- some of the options may be
hidden
, and should not be suggested - the built-in help option does not appear in the array, and you might want to suggest it
Both can be supported by hand fairly easily. Or you can optionally use the Help object to give you a list of the visible options for a command, which handles these two cases. e.g.
import { Command, Option } from 'commander';
const program = new Command();
program.option('-d, --debug', 'output extra debugging');
program.addOption(new Option('-s, --secret', 'internal use only').hideHelp());
console.log('options array');
console.log(program.options.map(o => o.flags));
console.log('visible options');
const helper = program.createHelp();
console.log(helper.visibleOptions(program).map(o => o.flags));
% node index.mjs
options array
[ '-d, --debug', '-s, --secret' ]
visible options
[ '-d, --debug', '-h, --help' ]
The type of approach sir @shadowspawn proposed definitely could have been a choice for solving this issue and if fact this approach is also being used in the CLI to get options for help command to output.
However, this approach has an issue in this case.
The webpack-cli when executed runs under the hood a method run()
this method is build on top of CLI class and and is responsible to initialize any command that is asked for. The issue is when executeAutoComplete()
(The function responsible for giving back autocomplete suggestions) is executed, there is no context of any command to this function and when run, console.log(this.program.commands)
it just returns an empty array.
This needs to be fixed or we will have to take any other approach. I welcome any suggestions from community as it will definitely speed up the process.
@HyperDanisH please in which file/folder should this be added to?
@HyperDanisH please in which file/folder should this be added to?
What be added?
@HyperDanisH please in which file/folder should this be added to?
What be added?
The Auto-Tab completion feature
I think you need to check pr related to this issue that is draft I made.
I think you need to check pr related to this issue that is draft I made.
Oh alright, I have seen it .