Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to have a shortcut to barreling command for a hard-coded folder? #96

Open
matthewkooshad opened this issue Sep 19, 2023 · 8 comments
Assignees
Labels
status: more info More information is required type: feat New feature or request

Comments

@matthewkooshad
Copy link

having to go to the explorer view, find lib folder, right click and choose the dartBarrelFileGenerator.generateCurrentWithSubfolders command from the context menu I think could be improved, if I could have a shortcut to barreling command for my lib folder. could you advise how to do that please?

@mikededo mikededo self-assigned this Sep 23, 2023
@mikededo mikededo added status: waiting response Waiting user reponse status: more info More information is required labels Sep 23, 2023
@mikededo
Copy link
Owner

Hey @matthewkooshad, thanks for opening an issue!!

I'm currently not aware of any direct solution, but obviously it would be a nice to have. AFAIK, it is possible to execute the commands from the command palette, where you can seach for generateCurrentWithSubfolders and the option wil show up.

The thing is that the extension would somehow need to know the path in which to generate the barrel file, which is why it has been developed to be used from the file explorer. How would you like it to work? Let's say you are editing a file in /src/widgets/widget-one.dart; where should the barrel file be made? I understand that in /src/widgets/index.dart, right?

@matthewkooshad
Copy link
Author

I also realized that I couldn't move forward using command, for what I'm looking for, which is:

I would like a hard-coded path ability to use with the command, as you said currently, it is unusable without explorer interaction. So, the path is not inferred as you're suggesting, but that the path could be simply provided to the command somehow, through hard-coded config or whatever means.

@mikededo
Copy link
Owner

Hmm, could you provide an example with the hardcoded configuration? What about multiple folders? I have thought about creating a cli tool, as an alternative, but it would be independent from VSCode

@matthewkooshad
Copy link
Author

matthewkooshad commented Sep 27, 2023

it doesn't matter much to me. i just want a command ability for a path.

a cli tool would work too.

if taking the hardcoded path approach, it could be a relative approach:
for example, i am looking to have it always be my lib folder that's always at the same relative position in a flutter app.

since the feature is not available right now that i was curious about, should we close this thread?
thanks for your efforts towards this cool tool -- the further convenience talked about here would make it even more of a time saver. thanks!

@mikededo
Copy link
Owner

The thing is that I believe I could make it work as a CLI tool quite easily (yet not meaning that the dev time will be short, as I have little spare time to invest in OS projects). Yesterday I was thinking to maybe have an NPM package, which could either be used with npx or simply installed globally. I know npm is not in the Dart's environment, but having written everything in TS, it would be way easier to publish it to NPM.

Example usages I have thought:

# dbfg is a shortcut for dart-barrel-file-generator 🥵
$ npx dbfg --mode nested-folders ./lib/some/path

# even maybe add the option to include multiple paths
$ dbfg --mode nested-folters ./lib/some/path ./lib/other/paths

@mikededo mikededo added type: feat New feature or request and removed status: waiting response Waiting user reponse labels Sep 27, 2023
@matthewkooshad
Copy link
Author

as i have npm, i'll be glad to report how it performs for me.

it would be nice to not have to see the bubble notification that the command executed too whenever it runs -- maybe that would happen naturally if using npm to run it as you showed.

also, i found i could put something like below in \AppData\Roaming\Code\User\keybindings.json (key bindings json command to open this file) to submit a command to terminal with a shortcut key:

{
    "key": "ctrl+shift+z",
    "command": "workbench.action.terminal.sendSequence",
    "args": {
      "text": "npx dbfg --mode nested-folders ./lib/some/path \u000D"
    }
  }

@mikededo
Copy link
Owner

mikededo commented Oct 4, 2023

Looks great. I did not know you could attach shortcuts to commands. Nonetheless, as said in other issues, I have barely time to work in this project. I will try to update it when possible.

@mikededo mikededo mentioned this issue Apr 5, 2024
@mikededo
Copy link
Owner

mikededo commented Apr 5, 2024

Answering this comment

Hmm, it is strange that the fsPath module cannot be found. I don't really know how VSCode runs commands under the hood. The main issue here is that the extension is not capable (as of now) of knowing the file path of the current focused file. That's why it requires to either right-click a folder or select a folder using the file selector.

My idea would be to add a new command that would only work when there's a file focused and it would allow the user to generate the barrel file for the current file parent folder, if there's any. This way, the user would be able to generate the barrel file without having to right-click a folder. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: more info More information is required type: feat New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants