documentation
This commit is contained in:
parent
0aebcfc02e
commit
690e9f541a
|
|
@ -37,7 +37,7 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
|
checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-sys",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -47,9 +47,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
|
checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"windows-sys",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
|
|
@ -102,6 +108,32 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colored"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"windows-sys 0.48.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "errno"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fastrand"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
|
|
@ -120,10 +152,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "lazy_static"
|
||||||
version = "0.2.151"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.155"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "linux-raw-sys"
|
||||||
|
version = "0.4.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
|
|
@ -179,6 +223,19 @@ dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustix"
|
||||||
|
version = "0.38.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"errno",
|
||||||
|
"libc",
|
||||||
|
"linux-raw-sys",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strsim"
|
name = "strsim"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
|
|
@ -196,12 +253,26 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tempfile"
|
||||||
|
version = "3.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"fastrand",
|
||||||
|
"rustix",
|
||||||
|
"windows-sys 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "term-header"
|
name = "term-header"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
|
"colored",
|
||||||
"rand",
|
"rand",
|
||||||
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -222,13 +293,37 @@ version = "0.11.0+wasi-snapshot-preview1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.48.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.48.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.52.0",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm 0.48.5",
|
||||||
|
"windows_aarch64_msvc 0.48.5",
|
||||||
|
"windows_i686_gnu 0.48.5",
|
||||||
|
"windows_i686_msvc 0.48.5",
|
||||||
|
"windows_x86_64_gnu 0.48.5",
|
||||||
|
"windows_x86_64_gnullvm 0.48.5",
|
||||||
|
"windows_x86_64_msvc 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -237,51 +332,93 @@ version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
|
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.52.0",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.52.0",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.52.0",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.52.0",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.52.0",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.52.0",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
|
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
|
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
|
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
|
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
|
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
|
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.52.0"
|
version = "0.52.0"
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,8 @@ publish = ["gitea"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.4.12", features = ["derive"] }
|
clap = { version = "4.4.12", features = ["derive"] }
|
||||||
|
colored = "2.1.0"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempfile = "3.10.1"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) [year] [fullname]
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
# term-header
|
||||||
|
|
||||||
|
`term-header` is a Rust-based command-line tool that generates customizable ASCII art terminal headers. These headers can be added to your .bashrc or other startup files to personalize the appearance of your terminal each time it starts.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Customizable Headers:** Use ASCII art files to create unique headers.
|
||||||
|
- **Color Options:** Specify text color for your headers (note that terminal themes may cause unexpected behavior).
|
||||||
|
- **Flexible Paths:** Configure paths for titles, art, and banners.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### From Source
|
||||||
|
|
||||||
|
1. Ensure you have Rust installed. If not, you can install it from [rust-lang.org](https://www.rust-lang.org/learn/get-started).
|
||||||
|
|
||||||
|
2. Clone the repository:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://vcs.r0r-5chach.xyz/r0r-5chach/term-header.git
|
||||||
|
cd term-header
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Build the project:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo build --release
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Optionally, install the binary globally:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cargo install --path .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using Pre-built Binaries
|
||||||
|
|
||||||
|
Check the [Releases](https://vcs.r0r-5chach.xyz/r0r-5chach/term-header/releases) page for pre-built binaries.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Run term-header with the following options:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
|
||||||
|
term-header [OPTIONS]
|
||||||
|
|
||||||
|
Options
|
||||||
|
|
||||||
|
-t, --titles-path <TITLES_PATH>
|
||||||
|
The path to the ASCII text files directory (default: ./titles/).
|
||||||
|
|
||||||
|
-a, --art-path <ART_PATH>
|
||||||
|
The path to the ASCII image files directory (default: ./art/).
|
||||||
|
|
||||||
|
-b, --banner-path <BANNER_PATH>
|
||||||
|
The path to the ASCII banner (default: ./banner.txt).
|
||||||
|
|
||||||
|
-c, --color <COLOR>
|
||||||
|
The color the text should be outputted as. Note that terminal themes can cause unexpected behavior.
|
||||||
|
|
||||||
|
-h, --help
|
||||||
|
Print help information.
|
||||||
|
|
||||||
|
-V, --version
|
||||||
|
Print the version number.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Add a simple header to your terminal startup by configuring your .bashrc:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
|
||||||
|
# Add this line to your .bashrc
|
||||||
|
term-header -t ./path/to/titles/ -a ./path/to/art/ -b ./path/to/banner.txt -c green
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! If you have suggestions, issues, or feature requests, please open an issue or submit a pull request.
|
||||||
|
|
||||||
|
1. Fork the repository.
|
||||||
|
2. Create a new branch (git checkout -b feature/your-feature).
|
||||||
|
3. Make your changes.
|
||||||
|
4. Commit your changes (git commit -am 'Add some feature').
|
||||||
|
5. Push to the branch (git push origin feature/your-feature).
|
||||||
|
6. Create a new Pull Request.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the MIT License. See the LICENSE file for more details.
|
||||||
28
init
28
init
|
|
@ -1,28 +0,0 @@
|
||||||
TITLE="/home/$USER/.config/zsh/titles/title-$(( $RANDOM % 45 + 1 ))"
|
|
||||||
ART="/home/$USER/.config/zsh/art/art-$(( $RANDOM % 22 + 1 ))"
|
|
||||||
|
|
||||||
print() {
|
|
||||||
for (( i=0; i<${#1}; i++ )); do
|
|
||||||
CHAR=${1:$i:2}
|
|
||||||
|
|
||||||
if [[ ${CHAR:1:1} = $'\n' ]]; then
|
|
||||||
printf '%s\n' ${CHAR}
|
|
||||||
else
|
|
||||||
CHAR=${1:$i:1}
|
|
||||||
if [[ ${CHAR} != " " ]]; then
|
|
||||||
sleep 0.005s
|
|
||||||
printf '%s' ${GREEN}${CHAR}
|
|
||||||
else
|
|
||||||
printf '%s' " "
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
print "$(cat ${TITLE})" | lolcat
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
print "$(cat ${ART})" | lolcat
|
|
||||||
echo
|
|
||||||
print "----------------8<------------------------8<------------------[ cut here ]----------------8<------------------------8<------------------" | lolcat
|
|
||||||
echo
|
|
||||||
|
|
@ -1,31 +1,78 @@
|
||||||
|
//! Logic to define and parse a configuration from command line arguments.
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use colored::Color;
|
||||||
|
/// Contains all the arguments parsed from the command line.
|
||||||
|
///
|
||||||
|
/// # Fields
|
||||||
|
///
|
||||||
|
/// - `titles_path`: Specifies the path to the ASCII text files directory. If not provided, assumes the directory is in the current directory.
|
||||||
|
/// - `art_path`: Specifies the path to the ASCII image files directory. If not provided, assumes the directory is in the current directory.
|
||||||
|
/// - `banner_path`: Specifies the path to the ASCII banner file. If not provided, assumes the file is in the current directory.
|
||||||
|
/// - `color`: Specifies the color to output the terminal header as. If not provided, outputs as normal.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
/// ```
|
||||||
|
/// use clap::Parser;
|
||||||
|
/// use term_header::config;
|
||||||
|
///
|
||||||
|
/// let args = config::Args::parse();
|
||||||
|
///
|
||||||
|
/// assert_eq!(args.titles_path, "./titles/");
|
||||||
|
/// assert_eq!(args.art_path, "./art/");
|
||||||
|
/// assert_eq!(args.banner_path, "./banner.txt");
|
||||||
|
/// assert_eq!(args.color, None);
|
||||||
|
/// ```
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(
|
||||||
|
name = "term-header",
|
||||||
|
author = "r0r-5chach",
|
||||||
|
version = "1.0",
|
||||||
|
about = "A program that generates ASCII art terminal headers.
|
||||||
|
color can cause unexpected behaviour when used with terminal themes.",
|
||||||
|
long_about = None)]
|
||||||
pub struct Args {
|
pub struct Args {
|
||||||
#[arg(short, long, default_value = "titles/")]
|
/// The path to the ASCII text files directory
|
||||||
titles_path: String,
|
#[arg(short, long, default_value = "./titles/")]
|
||||||
#[arg(short, long, default_value = "art/")]
|
pub titles_path: String,
|
||||||
art_path: String,
|
|
||||||
#[arg(short, long, default_value = "banner.txt")]
|
|
||||||
banner_path: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/// The path to the ASCII image files directory
|
||||||
|
#[arg(short, long, default_value = "./art/")]
|
||||||
|
pub art_path: String,
|
||||||
|
|
||||||
|
/// The path to the ASCII banner
|
||||||
|
#[arg(short, long, default_value = "./banner.txt")]
|
||||||
|
pub banner_path: String,
|
||||||
|
|
||||||
|
/// The color the text should be outputed as (Terminal themes can cause unexpected behaviour)
|
||||||
|
#[arg(short, long, default_value = None)]
|
||||||
|
pub color: Option<Color>,
|
||||||
|
}
|
||||||
|
/// Contains the configuration for the program.
|
||||||
|
///
|
||||||
|
/// # Fields
|
||||||
|
/// - `title_file`: The contents of the randomly selected ASCII text file.
|
||||||
|
/// - `art_file`: The contents of the randomly selected ASCII image file.
|
||||||
|
/// - `banner_file`: The contents of the randomly selected ASCII banner file.
|
||||||
|
///
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub title_file: String,
|
pub title_file: String,
|
||||||
pub art_file: String,
|
pub art_file: String,
|
||||||
pub banner_file: String,
|
pub banner_file: String,
|
||||||
|
pub color: Option<Color>,
|
||||||
}
|
}
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn new(args: Args) -> Self {
|
/// Returns a new configuration parsed from the [Args] parsed from the command line.
|
||||||
|
pub fn new(args: Args) -> Self { //TODO: Add examples using tempdir to create a dir
|
||||||
let title_file = rand_file_from_path(args.titles_path);
|
let title_file = rand_file_from_path(args.titles_path);
|
||||||
let art_file = rand_file_from_path(args.art_path);
|
let art_file = rand_file_from_path(args.art_path);
|
||||||
let banner_file = args.banner_path;
|
let banner_file = args.banner_path;
|
||||||
|
let color = args.color;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
title_file,
|
title_file,
|
||||||
art_file,
|
art_file,
|
||||||
banner_file,
|
banner_file,
|
||||||
|
color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,7 +94,12 @@ fn rand_file_from_path(path: String) -> String {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let mut file = path.clone();
|
let mut file = path.clone();
|
||||||
|
|
||||||
file.push_str(&rng.gen_range(1..get_file_count(&path)).to_string());
|
let file_count = get_file_count(&path);
|
||||||
|
|
||||||
|
match file_count {
|
||||||
|
count if count < 2 => file.push_str("1"),
|
||||||
|
_ => file.push_str(&rng.gen_range(1..get_file_count(&path)).to_string()),
|
||||||
|
}
|
||||||
file.push_str(".txt");
|
file.push_str(".txt");
|
||||||
|
|
||||||
file.to_string()
|
file.to_string()
|
||||||
|
|
|
||||||
88
src/lib.rs
88
src/lib.rs
|
|
@ -1,5 +1,15 @@
|
||||||
|
//! Generate Typewritter-style terminal headers.
|
||||||
|
//! Perfect for personalising the terminal.
|
||||||
|
//!
|
||||||
|
//! Provides an entrypoint to the binary.
|
||||||
|
//! Includes utility functions.
|
||||||
|
use colored::Color;
|
||||||
|
/// Handle parsing configuration from command line arguments.
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
/// Parses arguments passed to the command and generates a terminal header.
|
||||||
|
///
|
||||||
|
/// This function acts as the entrypoint to the main binary file. The function parses any command line arguments,
|
||||||
|
/// gathers the required files and outputs their contents to the terminal.
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
|
|
@ -10,33 +20,75 @@ pub fn run() {
|
||||||
let art = parse_file(&config.art_file);
|
let art = parse_file(&config.art_file);
|
||||||
let banner = parse_file(&config.banner_file);
|
let banner = parse_file(&config.banner_file);
|
||||||
|
|
||||||
type_writter_print(&title);
|
type_writer_print(&title, config.color);
|
||||||
print!("\n\n");
|
print!("\n\n");
|
||||||
type_writter_print(&art);
|
type_writer_print(&art, config.color);
|
||||||
print!("\n");
|
print!("\n");
|
||||||
type_writter_print(&banner);
|
type_writer_print(&banner, config.color);
|
||||||
}
|
}
|
||||||
|
/// Outputs the specified string in the specified color to stdout.
|
||||||
|
///
|
||||||
|
/// This function outputs each character of the specified [str] (str) to the terminal
|
||||||
|
/// with a 1ms delay in the specified [Color] (color).
|
||||||
|
/// If the character is a space or a new line the delay is increased to 5ms.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
/// ```
|
||||||
|
/// use std::time::{Duration, Instant};
|
||||||
|
///
|
||||||
|
/// let str = "Hello_World";
|
||||||
|
/// let time = Instant::now();
|
||||||
|
/// term_header::type_writer_print(str, None);
|
||||||
|
/// let time = time.elapsed();
|
||||||
|
///
|
||||||
|
/// //Checks that the output took longer to complete than the length of the string in milliseconds
|
||||||
|
/// assert!(time >= Duration::from_millis(str.len() as u64));
|
||||||
|
/// ```
|
||||||
|
pub fn type_writer_print(str: &str, color: Option<Color>) { //TODO: Add an example for with a color
|
||||||
|
use colored::Colorize;
|
||||||
|
use std::{io, thread, time::Duration};
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
fn type_writter_print(str: &str) { //TODO: add colors
|
str.chars().for_each(|char| {
|
||||||
use std::{ thread, time::Duration };
|
let mut delay = 1;
|
||||||
str.chars().for_each(|ch| {
|
if char != ' ' && char != '\n' {
|
||||||
if ch != ' ' && ch != '\n' {
|
delay = 5;
|
||||||
thread::sleep(Duration::from_millis(5));
|
|
||||||
}
|
}
|
||||||
print!("{}", ch);
|
thread::sleep(Duration::from_millis(delay));
|
||||||
|
|
||||||
|
let output = match color {
|
||||||
|
Some(color) => char.to_string().color(color),
|
||||||
|
None => char.to_string().normal(),
|
||||||
|
};
|
||||||
|
|
||||||
|
print!("{output}");
|
||||||
|
|
||||||
|
io::stdout().flush().unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/// Returns a [str] containing the contents of the file at [str] (path).
|
||||||
fn parse_file(path: &str) -> String {
|
///
|
||||||
|
/// # Examples
|
||||||
|
/// ```
|
||||||
|
/// use std::io::Write;
|
||||||
|
/// use tempfile::NamedTempFile;
|
||||||
|
///
|
||||||
|
/// let mut file = NamedTempFile::new().unwrap();
|
||||||
|
/// file.write_all(b"Hello_World").unwrap();
|
||||||
|
///
|
||||||
|
/// let result = term_header::parse_file(file.path().to_str().unwrap());
|
||||||
|
///
|
||||||
|
/// assert_eq!(result, "Hello_World");
|
||||||
|
/// ```
|
||||||
|
pub fn parse_file(path: &str) -> String {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
match fs::read_to_string(path) {
|
match fs::read_to_string(path) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(_) => file_not_found_error(path),
|
Err(_) => {
|
||||||
}
|
eprintln!("Failed to read path: {path}");
|
||||||
}
|
|
||||||
|
|
||||||
fn file_not_found_error(path: &str) -> ! {
|
"".to_string()
|
||||||
eprintln!("This file could not be found: {}", path);
|
},
|
||||||
std::process::exit(1)
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
|
/// Entrypoint for the main binary.
|
||||||
fn main() {
|
fn main() {
|
||||||
|
term_header::run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue