Skip to content

Commit

Permalink
Merge pull request #102 from HaoboGu/main
Browse files Browse the repository at this point in the history
Add support for -h/--help arg
  • Loading branch information
Urhengulas authored Oct 28, 2024
2 parents 8ef7856 + 5e514c3 commit 515c54c
Show file tree
Hide file tree
Showing 2 changed files with 15 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
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ 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 let None | Some("--help" | "-h") = raw_args.first().map(String::as_str) {
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 515c54c

Please sign in to comment.