Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for -h/--help arg #102

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
) {
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved
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
Loading