aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-05-04 23:29:16 +0200
committerTeddy Wing2021-05-04 23:29:16 +0200
commite12178ffac507065d96ae8a5e1e3f33c6d05833a (patch)
tree44b3966616f9725663d882d06094572cdec5da68
parent6afe10b7ab6bc3ab6e096cdd219ea078d4a02b44 (diff)
downloadpdf-form-replace-font-e12178ffac507065d96ae8a5e1e3f33c6d05833a.tar.bz2
Add sysexits exit code
Doesn't capture input or I/O errors. Not bothering to return EX_NOINPUT or EX_IOERR or EX_CANTCREAT because I don't want to bother creating an error enum and variants for each case.
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs4
3 files changed, 12 insertions, 0 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 20315d7..b765c85 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -141,6 +141,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
[[package]]
+name = "exitcode"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193"
+
+[[package]]
name = "flate2"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -252,6 +258,7 @@ name = "pdf-form-replace-font"
version = "0.0.1"
dependencies = [
"anyhow",
+ "exitcode",
"getopts",
"lopdf",
]
diff --git a/Cargo.toml b/Cargo.toml
index 91ced45..5e06e7e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,5 +5,6 @@ edition = "2018"
[dependencies]
anyhow = "1.0.40"
+exitcode = "1.1.2"
getopts = "0.2.21"
lopdf = "0.26.0"
diff --git a/src/main.rs b/src/main.rs
index 492707f..957dbe6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,8 +1,10 @@
use anyhow::{self, Context};
+use exitcode;
use getopts::Options;
use lopdf::{Document, Object};
use std::env;
+use std::process;
fn main() {
@@ -10,6 +12,8 @@ fn main() {
Ok(_) => (),
Err(e) => {
eprintln!("error: {}", e);
+
+ process::exit(exitcode::SOFTWARE);
},
};
}