README.md (2760B) 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| | |
51| `-r, --recursive` | recursively search in directories |
52| `-i, --inline` | changes the input |
53| `-o, --output <path>` | writes to `path` rather then writing to STDOUT |
54
55## TODO's
56
57- [x] recursive searching (`v0.2.0`)
58- [ ] watch-mode (struggling with save-timings - can clear files)
59 - you can add importsort-d into your onSave-hooks (e. g. [Run on Save](https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave) on VSCode)
60- [ ] support multiple imports in one line (demilited by `;`)
61- [ ] stripping unused imports (maybe)
62
63## Changelog
64
65### `v0.1.0`
66- the very first version
67- not a lot is implemented
68
69### `v0.2.0`
70- added `--recursive` (see above)
71- option `--keep` becomes disabling formatting
72- option `--inline` doen't copy the original but creates a `*.new` and renames it afterwards
73- option `--original` becomes `--binding` and sorts by original by default
74- refactoring code
75
76## License
77
78This whole project is licensed under the beautiful terms of the `zlib-license`.
79
80Further information [here](LICENSE)
81
82> made with love and a lot of cat memes