Skip to content

Commit

Permalink
Convert debug into an argument instead of a flag
Browse files Browse the repository at this point in the history
Upgrade actions/checkout and bump version
  • Loading branch information
dormant-user committed Feb 14, 2024
1 parent 4a98d36 commit a44bf53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Package Name
run: |
name=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://doc.rust-lang.org/cargo/getting-started/first-steps.html#first-steps-with-cargo
[package]
name = "none-shall-pass"
version = "0.1.5"
version = "0.1.6"
description = "Artifact for GitHub Action to validate hyperlinks in all markdown files"
license = "MIT"
documentation = "https://thevickypedia.github.io/none-shall-pass"
Expand Down
18 changes: 14 additions & 4 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ pub fn arguments() -> Args {
let mut i = 1; // Start from the second argument (args[0] is the program name).
while i < args.len() {
match args[i].as_str() {
"debug" => {
debug = true;
}
"-h" | "--help" => {
let helper = "Takes the arguments, debug, \
--owner, --repo, --exclude, and --version/-v\n\n\
debug: Optional flag to enable debug level logging.\n\
--debug: Optional boolean value to enable debug level logging.\n\
--owner: The account owner of the repository. The name is not case sensitive.\n\
--repo: The name of the repository without the .git extension. The name is not case sensitive.\n\
--exclude: Optional list of hostnames (whitespace separated) to be excluded.\n"
Expand Down Expand Up @@ -72,6 +69,19 @@ pub fn arguments() -> Args {
exit(1)
}
}
"--debug" => {
i += 1; // Move to the next argument.
if i < args.len() {
debug = match args[i].clone().as_str() {
"true" => true, // true as true
"1" => true, // 1 as true
_ => false // anything else? set debug to false
}
} else {
println!("\n--debug\n\tInput requires a value [type=missing]\n");
exit(1)
}
}
_ => {
println!("Unknown argument: {}", args[i]);
exit(1)
Expand Down

0 comments on commit a44bf53

Please sign in to comment.