Skip to content

osfv_cli: cli: replace argparse with typer - #2

Open
iwanicki92 wants to merge 6 commits into
Dasharo:mainfrom
iwanicki92:cli
Open

osfv_cli: cli: replace argparse with typer#2
iwanicki92 wants to merge 6 commits into
Dasharo:mainfrom
iwanicki92:cli

Conversation

@iwanicki92

@iwanicki92 iwanicki92 commented Jul 26, 2026

Copy link
Copy Markdown

Usage, arguments and help should be mostly identical, order might've changed due to the way typer sorts the options.

  • --json argument was moved from global to subcommands where it is used (can readd if required to not break API).
  • Raise on rte sonoff failures, previously there was only printed information while code tried to continue
  • Additionaly fixed issue where 'osfv_cli rte' ignored --skip-snipeit command
  • about 400 less lines of code

I wanted to fix --skip-snipeit issue I noticed in 3mdeb/meta-rte#103, but when I saw how the CLI looked like (hundreds of lines of argparse and 200 lines of if/elseif) I decided to replace it first. Incidentally I also fixed the original issue. A lot of changes, but I think this will be easier to maintain.

osfv_cli -h:

image

osfv_cli rte -h:

image

@macpijan

Usage, arguments and help should be mostly identical, order might've
changed due to the way typer sorts the options.

- `--json` argument was moved from global to subcommands where it is used.
- Raise on `rte sonoff` failures, previously there was only printed
  information while code tried to continue
- Additionaly fixed issue where 'osfv_cli rte' ignored `--skip-snipeit`
  command
- about 400 less lines of code

Signed-off-by: iwanicki92 <iwanicki92@gmail.com>
iwanicki92 and others added 4 commits July 26, 2026 17:14
- Run only after typer validation is done, so heavy setup function doesn't
  run for command that will fail due to missing argument anyway
- Make sure to always check_in assets that were checked_out
- Add decorator that'll run setup and queue cleanup to run when
  required.

Signed-off-by: iwanicki92 <iwanicki92@gmail.com>
Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
- Restore reset_cmos command name (Typer default renamed it to reset-cmos)
- Fix sonoff --sonoff_ip option, which was mistakenly declared as --rte_ip
- Apply with_setup to `spi on` by fixing decorator order, so checkout runs
- Restore pwr off/off_ex default press time to 6 seconds
- Restore user_add --company-name default (3mdeb) instead of requiring it
- Restore required --rom for flash_image_check
- Add -j short alias to the per-command --json flags
- Add exists=True to `flash write --rom`
- Correct power_on_ex docstring (verifies the LED turns on, not off)
- Remove dead rte_status function

Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
- Append to `failed` instead of reassigning it to the None returned by list.append()
- Print the failed assets in the failure message

Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
@m-iwanicki

Copy link
Copy Markdown
Contributor

Fixed couple bugs (asset_id is of type int not str) and API regressions + one unrelated bug. Tested couple commands and they work, e.g. check_in/check_out, rte serial, rte flash probe, rte psu get and couple others. rte subcommands correctly check out and check in assets that were not checked-out before the command, and correctly detect that asset is already checked out and don't check-it in in that case.

@macpijan

Copy link
Copy Markdown
Collaborator

Let's wait for @artur-rs with merging this.

Signed-off-by: iwanicki92 <iwanicki92@gmail.com>
@iwanicki92

Copy link
Copy Markdown
Author

I forgot to run pre-commit previously, I updated the hooks and fixed the issues.

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.

3 participants