mkfile

Crates.iomkfile
lib.rsmkfile
version0.4.0
created_at2023-11-01 10:30:42.735207+00
updated_at2025-07-29 14:28:18.765044+00
descriptionCLI app for creating text files like mkdir.
homepage
repositoryhttps://github.com/AlexWanderman/mkfile
max_upload_size
id1020832
size18,716
Alex Wanderman (AlexWanderman)

documentation

README

Overview Crates.io

Small CLI program written in Rust that creates text files. This program supports creating files with parents, with text and with Unix permissions. Can perform verbose and dry (without creating files) runs.

This program handles errors gracefully. If an error occurs, such as being unable to create a file, it will display an error message but will not delete any files or directories that have already been created. The program will continue executing and will not stop after encountering an error.

File access mode is only available for Unix. This program was not yest tested on Windows.

Install

Install with cargo install mkfile.

Options

  • d or dry: perform "dry" run, always verbose
  • v or verbose: print a message for each successful file (by default only for errors)
  • p or parents: create parent directories recursively
  • o or overwrite: overwrite already existing files
  • text "STRING": default text for every file
  • mode rwxrwxrwx: access mode for files after this option
  • help: print this help and exit
  • version: print version information and exit

Mode option is only applied for files that go after it and only for files (directories are not affected).

Text option is applied for all files.

Usage example

Assume following examples are run in users home directory.

The most basic example. New file with text and permissions to be read-write for owner, read for group and none for others. Verbose output. mkfile -v --text "Example" --mode rw-r----- file.txt /home/user/file.txt: Was created [mode 640].

Creating new file with parent directory. mkfile -vp dir/file.txt /home/user/dir/file.txt: Was created with parent.

Preview a bunch of files without actually creating them. mkfile -d file{1..3}.txt dir/file{1..3}.txt

/home/user/Documents/Rust/mkfile/file1.txt: To be created.
/home/user/Documents/Rust/mkfile/file2.txt: To be created.
/home/user/Documents/Rust/mkfile/file3.txt: To be created.
/home/user/Documents/Rust/mkfile/dir/file1.txt (for parent): Parent does not exist.
/home/user/Documents/Rust/mkfile/dir/file2.txt (for parent): Parent does not exist.
/home/user/Documents/Rust/mkfile/dir/file3.txt (for parent): Parent does not exist.

Future ideas

  • Exclude permission stuff from running on Windows
  • Color output
  • Undo partial changes on error
  • Change text for error messages
  • Move file/parent creation in a function
  • Parse text and substitute some patterns
Commit count: 12

cargo fmt