Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/man page #52

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,56 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# # Compiled Java class files
# *.class

# # Compiled Python bytecode
# *.py[cod]

# # Log files
# *.log

# # Package files
# *.jar

# # Maven
# target/
# dist/

# # JetBrains IDE
# .idea/

# # Unit test reports
# TEST*.xml

# # Generated by MacOS
# .DS_Store

# # Generated by Windows
# Thumbs.db

# # Applications
# *.app
# *.exe
# *.war

# # Large media files
# *.mp4
# *.tiff
# *.avi
# *.flv
# *.mov
# *.wmv

# # Data
# *.csv
# *.xls
# *.xlsx
# *.zip

# # Pickle files
# .pkl

# # Visualizations
# .png
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ repository = "https://github.com/sonalake/snmp-sim-rust.git"
readme = "README.md"
keywords = ["snmp", "simulator"]
categories = ["command-line-utilities", "simulation", "simulation::snmp"]
default-run = "snmp_sim"
default-run = "snmp-sim"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
path = "src/lib.rs"

[[bin]]
path = "src/main.rs"
name = "snmp_sim"
name = "snmp-sim"

[[bin]]
path = "src/bin/generate_spec.rs"
Expand All @@ -34,6 +34,7 @@ snmp-data-parser = { path = "./crates/snmp-data-parser" }
rasn-snmp = { path = "./crates/rasn/standards/snmp" }
rasn-smi = { path = "./crates/rasn/standards/smi" }
rasn = { path = "./crates/rasn" }
clap = { version = "3.2.6", features = ["derive"] }

actix = "0.13"
actix-web = { version = "4.1", default_features = false, features = [
Expand Down Expand Up @@ -106,6 +107,7 @@ lazy_static = "1.4"
static_init = "1.0"
ctor = "0.1.22"
signal-child = "1"
clap = "3.2"

[features]
integration-tests = ["visibility"]
Expand Down Expand Up @@ -133,3 +135,7 @@ members = [

[patch.crates-io]
paperclip = { git = "https://github.com/sonalake/paperclip", branch = "master" }

[build-dependencies]
clap_mangen = "0.1"
clap = "3.2"
20 changes: 19 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
use std::ffi::OsString;

// generated by `sqlx migrate build-script`
fn main() {
fn main() -> std::io::Result<()> {
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed=migrations");
println!("cargo:rerun-if-env-changed=MAN_DIR");

let package_name: &str = env!("CARGO_PKG_NAME");
let man_dir = std::path::PathBuf::from(std::env::var_os("MAN_DIR").map_or(OsString::from("./man"), |v| v));

let cmd = clap::Command::new(package_name)
.arg(clap::arg!(-n --name <NAME>))
.arg(clap::arg!(-c --count <NUM>));

let man = clap_mangen::Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer)?;

std::fs::write(man_dir.join(format!("{}.1", package_name)), buffer)?;

Ok(())
}