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

Add argument to sort some files only? #27

Closed
crizant opened this issue Jul 21, 2020 · 13 comments
Closed

Add argument to sort some files only? #27

crizant opened this issue Jul 21, 2020 · 13 comments
Assignees

Comments

@crizant
Copy link

crizant commented Jul 21, 2020

Hi, I would like to use this together with my git hook, and have my changed files sorted only.
It would be great to having a way to sort only a subset of files, instead of sorting all of them.

@github-actions
Copy link

👋 Hello! Thanks for submitting a issue 😄! @Matt-Gleich Will try to respond as soon as possible.

@gleich
Copy link
Member

gleich commented Jul 21, 2020

You can configure what files to sort right now using the config. Does this not work for you?

https://github.com/fluttercommunity/import_sorter#%EF%B8%8F-config

@crizant
Copy link
Author

crizant commented Jul 21, 2020

But how to select files with command arguments?
I want to do it In my git hook config files like:

sort-imports:
      glob: "*.dart"
      run: flutter pub run import_sorter:main {staged_files} && git add {staged_files}

@gleich
Copy link
Member

gleich commented Jul 21, 2020

Is there a reason you don't want them all sorted in this case?

@crizant
Copy link
Author

crizant commented Jul 21, 2020

Yes, I have hundreds of files in my repository and it makes the process a little bit slower; also there are a lot of unnecessary (and unwanted) outputs.

I want all files to be sorted, but only once. Then for every commits I made to my repository, the unchanged files doesn't need to be sorted, right?

@gleich
Copy link
Member

gleich commented Jul 21, 2020

Ahh, I see. This is a good idea! I will look into it and see how easy it would be to do something like this. Any updates I make will be posted in this issue thread.

@lig
Copy link
Contributor

lig commented Nov 14, 2020

@Matt-Gleich basically, it will be great to have this usable with IDEs/editors meaning sorting in a particular file and in a pre-commit hook, ideally, integrated in the pre-commit tool via pre-commit-config.yaml.

@gleich
Copy link
Member

gleich commented Nov 14, 2020

@lig do you think something like this would work well?

--files=bin/main.dart,lib/hello.dart

@davidlj95
Copy link

@lig do you think something like this would work well?

--files=bin/main.dart,lib/hello.dart

I think just positional arguments would be better to integrate with other tools like pre-commit

@gleich
Copy link
Member

gleich commented Nov 15, 2020

So something like this @davidlj95?

flutter pub run import_sorter:main bin/main.dart lib/hello.dart

@davidlj95
Copy link

So something like this @davidlj95?

flutter pub run import_sorter:main bin/main.dart lib/hello.dart

Yes!! ✨

@gleich gleich self-assigned this Nov 15, 2020
@gleich
Copy link
Member

gleich commented Nov 15, 2020

This is now in v4.3.0 of import_sorter! You can supply a list of files or a list of regular expressions to only sort certain files! Check the command line section in the docs for more information.

@gleich gleich closed this as completed Nov 15, 2020
@davidlj95
Copy link

This is now in v4.3.0 of import_sorter! You can supply a list of files or a list of regular expressions to only sort certain files! Check the command line section in the docs for more information.

Thanks!! 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants