webpack-cli icon indicating copy to clipboard operation
webpack-cli copied to clipboard

Feature:- AUTO TAB completion of flags

Open aman29271 opened this issue 4 years ago • 35 comments

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

aman29271 avatar Apr 01 '20 15:04 aman29271

Not sure it is possible, because completion is scope of bash/terminal

alexander-akait avatar Apr 01 '20 15:04 alexander-akait

something like this may possible - omelette

snitin315 avatar Apr 02 '20 04:04 snitin315

I am trying to implement this with yargs completion

aman29271 avatar Apr 05 '20 06:04 aman29271

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 avatar Apr 05 '20 06:04 anshumanv

@anshumanv any suggestions other than omelette

aman29271 avatar Apr 05 '20 10:04 aman29271

tabtab is another option.

jamesgeorge007 avatar Apr 05 '20 18:04 jamesgeorge007

We can't have it unless we move to new arg parser and start using flags from webpack core.

rishabh3112 avatar Apr 13 '20 05:04 rishabh3112

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.

webpack-bot avatar Oct 12 '20 23:10 webpack-bot

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

webpack-bot avatar Oct 28 '20 01:10 webpack-bot

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.

webpack-bot avatar Apr 28 '21 07:04 webpack-bot

bump

anshumanv avatar Apr 28 '21 07:04 anshumanv

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.

webpack-bot avatar Oct 27 '21 13:10 webpack-bot

bump

alexander-akait avatar Oct 27 '21 13:10 alexander-akait

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.

webpack-bot avatar Apr 27 '22 23:04 webpack-bot

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

webpack-bot avatar May 13 '22 01:05 webpack-bot

@snitin315 can I work on this issue or this issue is close due to inactivity ?

aialok avatar Oct 24 '23 04:10 aialok

@aialok feel free to work on it.

snitin315 avatar Oct 24 '23 08:10 snitin315

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 avatar Oct 24 '23 12:10 aialok

@aialok https://github.com/webpack/webpack/discussions/17441

evenstensberg avatar Nov 21 '23 20:11 evenstensberg

Relative: https://github.com/tj/commander.js/issues/385#issuecomment-1457773417

evenstensberg avatar Nov 21 '23 20:11 evenstensberg

Is the use of omelette good enough or tabtab be used?

HyperDanisH avatar Mar 07 '24 18:03 HyperDanisH

@alexander-akait what can be the best way to get all the flags that are built in webpack-cli, according to you.

HyperDanisH avatar Mar 19 '24 10:03 HyperDanisH

You can get them using commander API

alexander-akait avatar Mar 19 '24 12:03 alexander-akait

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' ]

shadowspawn avatar Mar 20 '24 06:03 shadowspawn

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 avatar Mar 21 '24 12:03 HyperDanisH

@HyperDanisH please in which file/folder should this be added to?

urizennnn avatar Mar 23 '24 14:03 urizennnn

@HyperDanisH please in which file/folder should this be added to?

What be added?

HyperDanisH avatar Mar 24 '24 05:03 HyperDanisH

@HyperDanisH please in which file/folder should this be added to?

What be added?

The Auto-Tab completion feature

urizennnn avatar Mar 24 '24 10:03 urizennnn

I think you need to check pr related to this issue that is draft I made.

HyperDanisH avatar Mar 24 '24 14:03 HyperDanisH

I think you need to check pr related to this issue that is draft I made.

Oh alright, I have seen it .

urizennnn avatar Mar 24 '24 18:03 urizennnn