Skip to content

Commit

Permalink
Add support for -h/--help arg
Browse files Browse the repository at this point in the history
Signed-off-by: Haobo Gu <haobogu@outlook.com>
  • Loading branch information
HaoboGu committed Oct 28, 2024
1 parent 8ef7856 commit 25bc28e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ fn notmain() -> Result<i32> {
// NOTE `skip` the name/path of the binary (first argument)
let raw_args = env::args().skip(1).collect::<Vec<_>>();

// If there's no argument provided, print the help message
if matches!(
raw_args
.iter()
.map(|s| s.as_str())
.collect::<Vec<&str>>()
.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() {
Expand Down

0 comments on commit 25bc28e

Please sign in to comment.