Skip to content

Commit f1f7471

Browse files
committed
chore: revert to getopts for argument parsing
1 parent 10a1ed8 commit f1f7471

File tree

10 files changed

+119
-270
lines changed

10 files changed

+119
-270
lines changed

Cargo.lock

Lines changed: 11 additions & 216 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ license = "MIT"
77
repository = "https://github.com/swellaby/rusty-hook"
88
readme = "README.md"
99
edition = "2018"
10-
keywords = [ "hooks", "githook", "git", "hook", "commit" ]
11-
categories = [ "development-tools" ]
10+
keywords = ["hooks", "githook", "git", "hook", "commit"]
11+
categories = ["development-tools"]
1212
exclude = [
1313
".coverage/**",
1414
".testresults/**",
@@ -32,16 +32,16 @@ exclude = [
3232

3333
[dependencies]
3434
ci_info = "0.14.2"
35-
clap = "3.0.0-beta.4"
36-
toml = "0.5.8"
35+
getopts = "0.2.21"
3736
nias = "0.7.0"
37+
toml = "0.5.8"
3838

3939
[build-dependencies]
4040
ci_info = "0.14.2"
4141
toml = "0.5.8"
4242
nias = "0.7.0"
4343

4444
[badges]
45-
azure-devops = { project = "swellaby/opensource", pipeline = "rusty-hook.linux-pr", build="49" }
45+
azure-devops = { project = "swellaby/opensource", pipeline = "rusty-hook.linux-pr", build = "49" }
4646
codecov = { repository = "swellaby/rusty-hook", branch = "master", service = "github" }
4747
maintenance = { status = "actively-developed" }

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#[path = "src/rusty_hook.rs"]
33
mod rusty_hook;
44

5+
use std::env;
56
use std::process::exit;
6-
use std::{env, vec};
77

88
fn main() {
99
if ci_info::is_ci() {
@@ -16,7 +16,7 @@ fn main() {
1616
nias::get_file_writer(),
1717
nias::get_file_existence_checker(),
1818
Some(&target_directory),
19-
vec![],
19+
&[],
2020
) {
2121
println!(
2222
"Fatal error encountered during initialization. Details: {}",

src/git.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn setup_hooks<F, G>(
4747
run_command: F,
4848
write_file: G,
4949
root_directory_path: &str,
50-
hook_file_skip_list: &[&str],
50+
hook_file_skip_list: &[String],
5151
) -> Result<(), String>
5252
where
5353
F: Fn(

src/hook_files/hook_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ else
2222
fi
2323

2424
# shellcheck disable=SC2046
25-
rusty-hook run --hook "${hookName}" $([ -z "$gitParams" ] && echo "" || echo "-- $gitParams")
25+
rusty-hook run --hook "${hookName}" "${gitParams}"
2626
handleRustyHookCliResult $? "${hookName}"

src/hooks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ pub fn create_hook_files<F>(
6767
write_file: F,
6868
root_directory_path: &str,
6969
hooks_directory: &str,
70-
hook_file_skip_list: &[&str],
70+
hook_file_skip_list: &[String],
7171
) -> Result<(), String>
7272
where
7373
F: Fn(&str, &str, bool) -> Result<(), String>,
7474
{
7575
let hook_file_contents = get_hook_file_contents();
7676
for hook in HOOK_NAMES
7777
.iter()
78-
.filter(|h| !hook_file_skip_list.contains(h))
78+
.filter(|h| !hook_file_skip_list.contains(&h.to_string()))
7979
{
8080
let path = get_file_path(root_directory_path, hooks_directory, hook);
8181
if write_file(&path, &hook_file_contents, true).is_err() {

src/hooks_test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,12 @@ mod create_hook_files_tests {
221221
assert!(make_executable);
222222
Ok(())
223223
};
224-
let result = create_hook_files(write_file, root_dir, git_hooks, &[EXP_SKIPPED_HOOK]);
224+
let result = create_hook_files(
225+
write_file,
226+
root_dir,
227+
git_hooks,
228+
&[String::from(EXP_SKIPPED_HOOK)],
229+
);
225230
assert_eq!(result, Ok(()));
226231
}
227232
}

0 commit comments

Comments
 (0)