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

use clap for cli argument parsing #18

Conversation

kinggoesgaming
Copy link
Contributor

@kinggoesgaming kinggoesgaming commented Oct 27, 2023

Before

hermit.com -h or hermit.com --help

hermit.com [-f <path_to_Hermitfile] [-o <output_path>]

If a path to a `Hermitfile` is not provided, it tries to load `Hermitfile` from
the current directory. If an `output_path` is not provided, the hermit is
written to `wasm.com` in the currently directly. On Unix-like operating systems
you must `chmod +x wasm.com` to make it executable. This is required because
WASI does not have a `chmod` function.

After

hermit.com -h

Usage: hermit.com [OPTIONS]

Options:
  -f <HERMITFILE_PATH>      Name of the Hermitfile [default: Hermitfile]
  -o <OUTPUT_PATH>          Output destination [default: wasm.com]
  -h, --help                Print help (see more with '--help')
  -V, --version             Print version

hermit.com --help

./build/hermit.com --help
Usage: hermit.com [OPTIONS]

Options:
  -f <HERMITFILE_PATH>
          Name of the Hermitfile

          [default: Hermitfile]

  -o <OUTPUT_PATH>
          Output destination.

          On `unix` platforms, you will need to run `chmod +x <OUTPUT_PATH>` to make it executable.
          This is required because WASI does not have a `chmod` function.

          [default: wasm.com]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

closes: #17

@kinggoesgaming
Copy link
Contributor Author

Waiting on #16, as it also touches the same lines as this PR.

I also need to add the chmod note to the docs.

Previously this was outputting `main.wasm`

Signed-off-by: Hunar Roop Kahlon <[email protected]>
Signed-off-by: Hunar Roop Kahlon <[email protected]>
@kinggoesgaming kinggoesgaming marked this pull request as ready for review October 28, 2023 23:02
@kinggoesgaming kinggoesgaming changed the title 17 use clap for cli argument parsing use clap for cli argument parsing Oct 29, 2023
@G4Vi
Copy link
Contributor

G4Vi commented Oct 30, 2023

Thanks, this looks cleaner and more maintainable than the hand parsing.

After you rebase and add the chmod note, could you please post size comparisons? I doubt this adds much, but I do want to be careful about hermit's size moving forward.

@kinggoesgaming
Copy link
Contributor Author

add the chmod note

I added that in a14c49f, however it is only visible under --help not -h. The way we can address is when the output is processed, we can print out (only on Unix-like OSes) to manually run chmod.

Main reason for the difference between the two is that clap prints only the first line of the doc for -h and the whole thing for --help.

mtb0x1 and others added 2 commits October 31, 2023 00:30
* feat: apply clippy suggestions and replace helper function with builtin one.
* feat: add a 'release' profile to hermit-cli to be used only when specified.
@kinggoesgaming
Copy link
Contributor Author

I am going to recreate this PR tomorrow. Messed up bad

@kinggoesgaming kinggoesgaming deleted the 17-use-clap-for-cli-argument-parsing branch November 1, 2023 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use clap for cli argument parsing
3 participants