From 6200678b49e541b0ad5714ffee5d4cc22cc8631c Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Mon, 27 Jun 2022 15:47:11 +0100 Subject: [PATCH 01/11] Update Cargo.toml --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 756271d..6d59256 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -133,3 +133,6 @@ members = [ [patch.crates-io] paperclip = { git = "https://github.com/sonalake/paperclip", branch = "master" } + +[build-dependencies] +clap_mangen = "0.1" From 68cc2d946dd4a0863305c6626a70f436afb5ef04 Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Mon, 27 Jun 2022 15:47:39 +0100 Subject: [PATCH 02/11] Update build.rs --- build.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index d506869..34b02b1 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,19 @@ // 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-changed=migrations"); + + let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); + + let cmd = clap::Command::new("mybin") + .arg(clap::arg!(-n --name )) + .arg(clap::arg!(-c --count )); + + let man = clap_mangen::Man::new(cmd); + let mut buffer: Vec = Default::default(); + man.render(&mut buffer)?; + + std::fs::write(out_dir.join("mybin.1"), buffer)?; + + Ok(()) } From 90e77de6c4d1bae64a70f572be84363c96956ba1 Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:24:40 +0100 Subject: [PATCH 03/11] Update .gitignore --- .gitignore | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/.gitignore b/.gitignore index 088ba6b..aeb5379 100644 --- a/.gitignore +++ b/.gitignore @@ -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 From 3c71edf32243326d7f8c8e71b8fae120e9d70f4b Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:29:52 +0100 Subject: [PATCH 04/11] Update .gitignore --- .gitignore | 78 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index aeb5379..280ffcb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,55 +9,55 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk -# Compiled Java class files -*.class +# # Compiled Java class files +# *.class -# Compiled Python bytecode -*.py[cod] +# # Compiled Python bytecode +# *.py[cod] -# Log files -*.log +# # Log files +# *.log -# Package files -*.jar +# # Package files +# *.jar -# Maven -target/ -dist/ +# # Maven +# target/ +# dist/ -# JetBrains IDE -.idea/ +# # JetBrains IDE +# .idea/ -# Unit test reports -TEST*.xml +# # Unit test reports +# TEST*.xml -# Generated by MacOS -.DS_Store +# # Generated by MacOS +# .DS_Store -# Generated by Windows -Thumbs.db +# # Generated by Windows +# Thumbs.db -# Applications -*.app -*.exe -*.war +# # Applications +# *.app +# *.exe +# *.war -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv +# # Large media files +# *.mp4 +# *.tiff +# *.avi +# *.flv +# *.mov +# *.wmv -# Data -*.csv -*.xls -*.xlsx -*.zip +# # Data +# *.csv +# *.xls +# *.xlsx +# *.zip -# Pickle files -.pkl +# # Pickle files +# .pkl -# Visualizations -.png +# # Visualizations +# .png From a8207592941a021adb726be24174d233df1c9b57 Mon Sep 17 00:00:00 2001 From: Conor Kinsella Date: Tue, 28 Jun 2022 13:01:49 +0100 Subject: [PATCH 05/11] Man page integration --- Cargo.toml | 2 ++ build.rs | 2 +- snmp-sim.db | Bin 0 -> 36864 bytes snmp-sim.db-shm | Bin 0 -> 32768 bytes snmp-sim.db-wal | 0 5 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 snmp-sim.db create mode 100644 snmp-sim.db-shm create mode 100644 snmp-sim.db-wal diff --git a/Cargo.toml b/Cargo.toml index 6d59256..2cd91e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = [ @@ -136,3 +137,4 @@ paperclip = { git = "https://github.com/sonalake/paperclip", branch = "master" } [build-dependencies] clap_mangen = "0.1" +clap = "3.2" \ No newline at end of file diff --git a/build.rs b/build.rs index 34b02b1..92b6de8 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ // generated by `sqlx migrate build-script` fn main() -> std::io::Result<()> { // trigger recompilation when a new migration is added - //println!("cargo:rerun-if-changed=migrations"); + // println!("cargo:rerun-if-changed=migrations"); let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); diff --git a/snmp-sim.db b/snmp-sim.db new file mode 100644 index 0000000000000000000000000000000000000000..68d6898a244aca74840f347dd9b9e55c3a2902b8 GIT binary patch literal 36864 zc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wb zDuB=b=mrpg00bZa0SG_<0uX=z1Rwx`sV{*4|DXD8j3 Date: Tue, 28 Jun 2022 13:07:15 +0100 Subject: [PATCH 06/11] Update build.rs --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 92b6de8..c23b74f 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,7 @@ fn main() -> std::io::Result<()> { // trigger recompilation when a new migration is added // println!("cargo:rerun-if-changed=migrations"); - let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); + let man_dir = std::path::PathBuf::from(std::env::var_os("MAN_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); let cmd = clap::Command::new("mybin") .arg(clap::arg!(-n --name )) @@ -13,7 +13,7 @@ fn main() -> std::io::Result<()> { let mut buffer: Vec = Default::default(); man.render(&mut buffer)?; - std::fs::write(out_dir.join("mybin.1"), buffer)?; + std::fs::write(man_dir.join("mybin.1"), buffer)?; Ok(()) } From 1db29e3cb629b9c4a351e68631db43aa61190951 Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:24:05 +0100 Subject: [PATCH 07/11] Update build.rs --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index c23b74f..7323405 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,7 @@ // generated by `sqlx migrate build-script` fn main() -> std::io::Result<()> { // trigger recompilation when a new migration is added - // println!("cargo:rerun-if-changed=migrations"); + println!("cargo:rerun-if-changed=migrations"); let man_dir = std::path::PathBuf::from(std::env::var_os("MAN_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); From d4e394548d54a89745981492d60313ef19bbb501 Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:25:11 +0100 Subject: [PATCH 08/11] Update Cargo.toml --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 2cd91e9..f033483 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,4 +137,4 @@ paperclip = { git = "https://github.com/sonalake/paperclip", branch = "master" } [build-dependencies] clap_mangen = "0.1" -clap = "3.2" \ No newline at end of file +clap = "3.2" From f90891dff57d22fc3833738d162a39bf01c5be18 Mon Sep 17 00:00:00 2001 From: conor-sonalake <104076301+conor-sonalake@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:42:03 +0100 Subject: [PATCH 09/11] Update build.rs --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 7323405..ff108fb 100644 --- a/build.rs +++ b/build.rs @@ -5,7 +5,7 @@ fn main() -> std::io::Result<()> { let man_dir = std::path::PathBuf::from(std::env::var_os("MAN_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); - let cmd = clap::Command::new("mybin") + let cmd = clap::Command::new("snmp_sim") .arg(clap::arg!(-n --name )) .arg(clap::arg!(-c --count )); @@ -13,7 +13,7 @@ fn main() -> std::io::Result<()> { let mut buffer: Vec = Default::default(); man.render(&mut buffer)?; - std::fs::write(man_dir.join("mybin.1"), buffer)?; + std::fs::write(man_dir.join("snmp_sim.1"), buffer)?; Ok(()) } From 641cc64c7a33b63f48c4b75cbe52c0aea7e40060 Mon Sep 17 00:00:00 2001 From: frankhorv Date: Tue, 28 Jun 2022 15:09:13 +0200 Subject: [PATCH 10/11] Fix man page build --- Cargo.toml | 5 +++-- build.rs | 12 ++++++++---- snmp-sim.db | Bin 36864 -> 0 bytes snmp-sim.db-shm | Bin 32768 -> 0 bytes snmp-sim.db-wal | 0 5 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 snmp-sim.db delete mode 100644 snmp-sim.db-shm delete mode 100644 snmp-sim.db-wal diff --git a/Cargo.toml b/Cargo.toml index f033483..0cfbe6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ 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] @@ -19,7 +19,7 @@ path = "src/lib.rs" [[bin]] path = "src/main.rs" -name = "snmp_sim" +name = "snmp-sim" [[bin]] path = "src/bin/generate_spec.rs" @@ -107,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"] diff --git a/build.rs b/build.rs index ff108fb..e70e838 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,15 @@ +use std::ffi::OsString; + // generated by `sqlx migrate build-script` fn main() -> std::io::Result<()> { // trigger recompilation when a new migration is added println!("cargo:rerun-if-changed=migrations"); - - let man_dir = std::path::PathBuf::from(std::env::var_os("MAN_DIR").ok_or_else(|| std::io::ErrorKind::NotFound)?); + println!("cargo:rerun-if-env-changed=MAN_DIR"); + + let package_name: &str = env!("CARGO_PKG_NAME").into(); + 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("snmp_sim") + let cmd = clap::Command::new(package_name) .arg(clap::arg!(-n --name )) .arg(clap::arg!(-c --count )); @@ -13,7 +17,7 @@ fn main() -> std::io::Result<()> { let mut buffer: Vec = Default::default(); man.render(&mut buffer)?; - std::fs::write(man_dir.join("snmp_sim.1"), buffer)?; + std::fs::write(man_dir.join(format!("{}.1", package_name)), buffer)?; Ok(()) } diff --git a/snmp-sim.db b/snmp-sim.db deleted file mode 100644 index 68d6898a244aca74840f347dd9b9e55c3a2902b8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 36864 zcmeI&ZEO=|00;2v>#b#7$$~V6ArJBano`(HGz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V{*4|DXD8j3 Date: Tue, 28 Jun 2022 15:22:01 +0200 Subject: [PATCH 11/11] removed useless conversion --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index e70e838..89fdbd7 100644 --- a/build.rs +++ b/build.rs @@ -6,7 +6,7 @@ fn main() -> std::io::Result<()> { println!("cargo:rerun-if-changed=migrations"); println!("cargo:rerun-if-env-changed=MAN_DIR"); - let package_name: &str = env!("CARGO_PKG_NAME").into(); + 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)