1
Fork 0
bautils/README.md

72 lines
1.6 KiB
Markdown
Raw Normal View History

2023-11-16 18:46:19 +00:00
# Bautils
> **Bauke's Ad-hoc Utilities.**
2023-11-18 16:50:30 +00:00
## Commands
### Arguments
2023-12-05 15:05:23 +00:00
```sh
fruits=("apple" "banana" "coconut")
bautils arguments count -- $fruits
# Outputs: 3
```
2023-11-18 16:50:30 +00:00
### Date
2024-01-16 11:18:11 +00:00
```sh
# 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'
```
2023-11-18 16:50:30 +00:00
### Directory
2024-01-16 11:18:11 +00:00
```sh
# 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'
```
2023-11-18 16:50:30 +00:00
### File
2024-01-16 11:18:11 +00:00
```sh
# 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
```
2023-11-18 16:50:30 +00:00
### Log
2024-01-16 11:18:11 +00:00
```sh
# 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!'
```
2023-11-18 16:50:30 +00:00
### Match
2024-01-16 11:18:11 +00:00
```sh
# Matches a regular expression, returning an exit code of 1 if it
# is succesful.
bautils match regex --pattern '\d' '123'
```
2023-11-16 18:46:19 +00:00
## License
Distributed under the [AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later.html) license, see [LICENSE](https://git.bauke.xyz/Bauke/bautils/src/branch/main/LICENSE) for more information.