1
Fork 0
Bauke's Ad-hoc Utilities
Go to file
Bauke ad067d252e
Update dependencies.
2024-01-22 12:32:33 +01:00
source Move the global lints to Cargo.toml. 2024-01-16 12:06:18 +01:00
.envrc Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
.gitignore Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
Cargo.lock Update dependencies. 2024-01-22 12:32:33 +01:00
Cargo.toml Update dependencies. 2024-01-22 12:32:33 +01:00
LICENSE Initial commit! 2023-10-29 18:05:15 +01:00
Makefile.toml Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
README.md Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
flake.lock Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
flake.nix Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
rustfmt.toml Add initial project files. 2023-10-31 14:51:57 +01:00
rustup-toolchain.toml Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00
shell.nix Add Nix flake and direnv files. 2024-01-22 12:31:21 +01:00

README.md

Bautils

Bauke's Ad-hoc Utilities.

Commands

Arguments

fruits=("apple" "banana" "coconut")
bautils arguments count -- $fruits
# Outputs: 3

Date

# Outputs the current date with the ISO 8601 format.
bautils date now

# Set a custom format using `-f` or `--format`.
bautils date now -f '%F %T'

Directory

# Checks whether a directory exists, returning an exit code of 1
# when it doesn't. This specifically checks for a directory so if
# a path exists but it isn't a directory this will also return 1.
bautils directory exists 'source'

File

# Checks whether a file exists, with the same logic as the
# `directory exists` command.
bautils file exists 'Cargo.toml'

# Returns metadata of a file, for example `--modified` returning
# when the file was last modified.
bautils file metadata 'Cargo.toml' --modified

# Returns parts of a file name.
bautils file parts 'source/main.rs' --directory # Outputs: source
bautils file parts 'source/main.rs' --basename  # Outputs: main
bautils file parts 'source/main.rs' --extension # Outputs: rs

Log

# Logs data to a file, creating the file if it doesn't exist.
bautils log -- 'The data to log!'

# The log file can be specified with `-f` or `--file`.
bautils log -f 'logfile.txt' -- 'More data!'

Match

# Matches a regular expression, returning an exit code of 1 if it
# is succesful.
bautils match regex --pattern '\d' '123'

Development

With Nix flakes and direnv installed and enabled, all the required dependencies are automatically loaded from shell.nix. Then cargo-make can be used to build, deploy and lint the code. The available tasks are all described in the Makefile.toml configuration.

License

Distributed under the AGPL-3.0-or-later license, see LICENSE for more information.