diff --git a/CHANGELOG.md b/CHANGELOG.md index 63641c1..cbc27d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- [#102] Add support for -h/--help arg and no arg + +[#102]: https://github.com/knurling-rs/flip-link/pull/102 + ## [v0.1.9] - 2024-08-14 - [#96] Add support for @file args diff --git a/src/main.rs b/src/main.rs index eac095d..5f8abbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,6 +29,24 @@ fn notmain() -> Result { // NOTE `skip` the name/path of the binary (first argument) let raw_args = env::args().skip(1).collect::>(); + // If there's no argument provided, print the help message + if matches!( + raw_args + .iter() + .map(|s| s.as_str()) + .collect::>() + .as_slice(), + [] | ["--help"] | ["-h"] + ) { + eprintln!( + "flip-link: adds zero-cost stack overflow protection to your \ + embedded programs\nYou should not use flip-link directly from \ + command line, use flip-link as your default linker instead. \n\n\ + For detailed usage, check https://github.com/knurling-rs/flip-link" + ); + return Ok(0); + } + { let exit_status = linking::link_normally(&raw_args)?; if !exit_status.success() {