1 unstable release
0.2.0 | Jun 6, 2022 |
---|---|
0.1.0 |
|
#16 in #development-tools
28KB
483 lines
dab
: The pursuit of laziness for Rustaceans
dab
is a command-line tool that is intended for Rust developers to savor their much deserved laziness
after fighting with async
lifetimes or FFI. Right now, it does one very simple thing: create modules.
Well, I got a little mad creating modules while I was working on Skytable. Silly? Read this!
Installation 🚀
Simply run:
$ cargo install dab
Usage
- Basic usage example:
dab modname
. This will create asrc/modname/mod.rs
file along with a module declaration (likemod modname
) in the "root file" which is eitherlib.rs
ormain.rs
depending on your crate type - Advanced usage example:
dab -cskip --dskip --public mymod
: This will create asrc/mymod.rs
file (note no directory creation), skip a license header in the "root file" (if any) and mark the module visibility to bepub
Features ✨
- Create modules in binary/library packages
- Choose if module is public/private (private by default)
- Ignore comments on top of file while adding modules ("license headers")
- Rewrite using
syn
- Support full paths to deeply nested modules
- Enable parent creation if it doesn't exist
- Auto add file-header comments ("license headers" for example) to newly create modules
- Provide a
dab.toml
configuration that will be read for determining settings - Run
rustfmt
on addingmod
entry to the root file - Support
cfg
attributes - Support workspaces:
- Support creating modules by package name (
skyd::protocol
) - Detect workspace root and operate from any other directory (much like what
cargo
does) - Support creation of packages in workspaces
- Support creating modules by package name (
- Open code editor to the newly created module
- Have ideas? Create an issue!
Background
Call it my personal itch, in large Rust projects I've been extremely annoyed while creating modules (especially in workspaces). The usual sequence was:
mkdir <package>/src/path/to/module
touch <package>/src/path/to/module/mod.rs
- Edit
main.rs
orlib.rs
to add the package the name - Open the code editor and add code
I wanted to trim this down to one step. Hence, this tool.
License
This tool is licensed under the Apache-2.0 License.
Dependencies
~0.6–1.2MB
~27K SLoC