README.md (3000B) download
1# Sort Imports for [D](https://dlang.org/)
2
3<img src="assets/importsort-d.png" alt="logo" width="256" />
4
5`sortimport-d` can sort your dozens of `import`'s in a `.d` file (no matter where)
6
7## Installation
8
9## Prerequisite
10
11- [`dub`](https://dub.pm/)
12
13### Building from HEAD
14
15Get the repository with `git` and compile everything with `dub`
16```
17$ git clone https://github.com/friedelschoen/importsort-d
18$ cd importsort-d
19$ dub build
20```
21
22If everything went fine, there should be a binary at `bin/importsort-d`.
23
24Copy this into a directory included in `$PATH` (`/usr/bin` for example) to make this command work globally.
25
26### Building with DUB
27
28```
29$ dub fetch importsort-d
30$ dub run importsort-d -- --help
31```
32
33This won't install the command globally, you always have to run `dub run importsort-d <args>`
34
35## Usage
36
37```
38$ importsort-d [-h] [-v] [-r] [-i] [-o <out>] [-k] [-a] [-r] <input...>
39```
40`input` may be omitted or set to `-` to read from STDIN
41
42| option | description |
43| --------------------- | ---------------------------------------------- |
44| `-h, --help` | prints a help message |
45| `-v, --verbose` | prints useful debug messages |
46| | |
47| `-k, --keep` | keeps the line as-is instead of formatting |
48| `-a, --attribute` | public and static imports first |
49| `-b, --binding` | sorts by binding rather then the original |
50| `-m, --merge` | merge imports which uses same file |
51| | |
52| `-r, --recursive` | recursively search in directories |
53| `-i, --inline` | changes the input |
54| `-o, --output <path>` | writes to `path` rather then writing to STDOUT |
55
56## TODO's
57
58- [x] recursive searching (`v0.2.0`)
59- [x] merge imports (`v0.3.0`)
60- [ ] watch-mode (struggling with save-timings - can clear files)
61 - you can add importsort-d into your onSave-hooks (e. g. [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) on VSCode)
62- [ ] support multiple imports in one line (demilited by `;`)
63- [ ] stripping unused imports (maybe)
64
65## Changelog
66
67### `v0.1.0`
68- the very first version
69- not a lot is implemented
70
71### `v0.2.0`
72- added `--recursive` (see above)
73- option `--keep` becomes disabling formatting
74- option `--inline` doen't copy the original but creates a `*.new` and renames it afterwards
75- option `--original` becomes `--binding` and sorts by original by default
76- refactoring code
77
78### `v0.3.0`
79- added `--merge` (see above)
80
81### `v0.3.1`
82- added documentation for contributers (or people who wan't to see my code)
83
84## License
85
86This whole project is licensed under the beautiful terms of the `zlib-license`.
87
88Further information [here](LICENSE)
89
90> made with love and a lot of cat memes