build: Create manpages for Vento.

I've backtracked from using Clap and instead will keep using my own
custom command parser. I'll be using the man crate instead. These
manpages have the new syntax which I'll implement in the following
commits. This also uses cargo-make to install the manpages because I
don't want the manpages being replaced everytime I rebuild.
This commit is contained in:
Lux Aliaga 2022-09-24 22:24:31 -03:00
parent 61235e7a63
commit 13e28e445c
Signed by: lux
GPG Key ID: B56C805968637437
5 changed files with 172 additions and 93 deletions

102
Cargo.lock generated
View File

@ -37,40 +37,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.2.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750"
dependencies = [
"atty",
"bitflags",
"clap_lex",
"indexmap",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "clap_mangen"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "105180c05a72388d5f5e4e4f6c79eecb92497bda749fa8f963a16647c5d5377f"
dependencies = [
"clap",
"roff",
]
[[package]]
name = "colored"
version = "2.0.0"
@ -128,12 +94,6 @@ dependencies = [
"wasi",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hermit-abi"
version = "0.1.19"
@ -143,16 +103,6 @@ dependencies = [
"libc",
]
[[package]]
name = "indexmap"
version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -165,6 +115,15 @@ version = "0.2.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5"
[[package]]
name = "man"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebf5fa795187a80147b1ac10aaedcf5ffd3bbeb1838bda61801a1c9ad700a1c9"
dependencies = [
"roff",
]
[[package]]
name = "num"
version = "0.2.1"
@ -229,12 +188,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "os_str_bytes"
version = "6.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
[[package]]
name = "proc-macro2"
version = "1.0.43"
@ -275,9 +228,9 @@ dependencies = [
[[package]]
name = "roff"
version = "0.2.1"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
checksum = "e33e4fb37ba46888052c763e4ec2acfedd8f00f62897b630cadb6298b833675e"
[[package]]
name = "size_format"
@ -289,12 +242,6 @@ dependencies = [
"num",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.99"
@ -306,21 +253,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
[[package]]
name = "thiserror"
version = "1.0.34"
@ -358,11 +290,10 @@ name = "vento"
version = "1.0.0"
dependencies = [
"anyhow",
"clap",
"clap_mangen",
"colored",
"dirs",
"fs_extra",
"man",
"size_format",
]
@ -388,15 +319,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"

View File

@ -11,6 +11,8 @@ repository = "https://codeberg.org/nixgoat/vento"
license = "GPL-3.0-or-later"
keywords = ["utility", "file-manager", "inventory"]
categories = ["command-line-utilities", "filesystem"]
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
@ -19,5 +21,7 @@ colored = "2.0.0"
fs_extra = "1.2.0"
anyhow = "1.0.65"
size_format = "1.0.2"
clap = "3.2.22"
clap_mangen = "0.1.11"
[build-dependencies]
man = "0.3.0"
anyhow = "1.0.65"

32
Makefile.toml Normal file
View File

@ -0,0 +1,32 @@
[tasks.install-binary]
command = "cargo"
args = ["install", "--path", "."]
[tasks.install-manpages]
condition = { platforms = ["linux", "mac"] }
script = [
"cp /tmp/vento-man/* $HOME/.local/share/man/man1/",
"rm -rf /tmp/vento-man"
]
[tasks.install]
dependencies = [
"install-binary",
"install-manpages"
]
[tasks.clean-binary]
command = "cargo"
args = ["clean"]
[tasks.clean-manpages]
condition = { platforms = ["linux", "mac"] }
script = [
"rm -rf /tmp/vento-man"
]
[tasks.clean]
dependencies = [
"clean-binary",
"clean-manpages"
]

View File

@ -4,10 +4,21 @@ Vento is a utility which allows you to manage your files as if you're playing an
## Install
Clone it using Git and build it with [Cargo](https://rustup.rs/)!
Clone the repository using Git.
```
$ git clone https://codeberg.org/nixgoat/vento.git && cd vento
```
The recommended method to install Vento is to use [cargo-make](https://crates.io/crates/cargo-make/0.3.54#usage-conditions-structure). This will install the binary and the manpages for Vento.
```
$ cargo make install
```
Otherwise you can build and install it with [Cargo](https://rustup.rs/). This will however not install the manpages.
```
$ cargo install --path .
```

110
build.rs Normal file
View File

@ -0,0 +1,110 @@
/*
* Vento, a CLI inventory for your files.
* Copyright (C) 2022 Lux Aliaga
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
use anyhow::Result;
use man::prelude::*;
use std::env;
use std::fs::{create_dir_all, File};
use std::io::Write;
fn main() -> Result<()> {
if cfg!(unix) {
let pages = [vento()?, take()?, drop()?];
let tempdir = env::temp_dir().join("vento-man");
create_dir_all(tempdir.clone())?;
for page in 0..pages.len() {
let tempfile = tempdir.join(pages[page].clone().1);
let mut file = File::create(tempfile).unwrap();
write!(&mut file, "{}", pages[page].clone().0).unwrap();
}
}
Ok(())
}
fn vento() -> Result<(String, String)> {
let page = Manual::new("vento")
.about("a CLI inventory for your files")
.author(Author::new("Lux Aliaga").email("they@mint.lgbt"))
.description("List files and directories in the currently active inventory, the files in SLOT, the files in DIRECTORY or the files in DIRECTORY in SLOT.")
.flag(
Flag::new()
.short("-s")
.long("--switch")
.help("Switches inventory slots"),
)
.flag(
Flag::new()
.short("-i")
.long("--init")
.help("Initializes Vento with all its respective directories"),
)
.flag(
Flag::new()
.short("-h")
.long("--help")
.help("Shows the help message"),
)
.arg(Arg::new("[SLOT]"))
.arg(Arg::new("[DIRECTORY]"))
.custom(
Section::new("before starting")
.paragraph("Vento will first need to initialize the respective directories before usage. Do this by running vento -i.")
)
.render();
Ok((page, String::from("vento.1")))
}
fn take() -> Result<(String, String)> {
let page = Manual::new("take")
.about("a file grabber for Vento")
.author(Author::new("Lux Aliaga").email("they@mint.lgbt"))
.description("Take FILE and put it in the inventory.")
.option(
Opt::new("slot")
.short("-s")
.long("--slot")
.help("The slot to put the file in"),
)
.arg(Arg::new("FILE"))
.render();
Ok((page, String::from("take.1")))
}
fn drop() -> Result<(String, String)> {
let page = Manual::new("drop")
.about("a file dropper for Vento")
.author(Author::new("Lux Aliaga").email("they@mint.lgbt"))
.description("Take FILE off the inventory and drop it in DESTINATION.")
.option(
Opt::new("slot")
.short("-s")
.long("--slot")
.help("The slot to take the file from"),
)
.arg(Arg::new("FILE"))
.arg(Arg::new("[DESTINATION]"))
.render();
Ok((page, String::from("drop.1")))
}