Skip to content

Clap#1689

Draft
tsanona wants to merge 4 commits intolibrespot-org:devfrom
tsanona:clap
Draft

Clap#1689
tsanona wants to merge 4 commits intolibrespot-org:devfrom
tsanona:clap

Conversation

@tsanona
Copy link
Copy Markdown

@tsanona tsanona commented Feb 26, 2026

Changes to move from opt into clap cli
Done:

  • Moved cli/config code away from main.
  • Refactored some code to better fit clap (ex: implement BACKENDS list as an enum)
  • Made discovery truly conditionally compiled.

TODO:

  • It's missing some validation procedures.
  • styling to make the cli look nice.

I will continue to work on approximating this solution as close as possible to the previous cli flow.
Mean while I would love to get some comments.

@kingosticks
Copy link
Copy Markdown
Contributor

Given how much there is for someone to review here, could you explicitly outline what the benefit of this is?

@tsanona
Copy link
Copy Markdown
Author

tsanona commented Mar 3, 2026

The main objective was to simplify the main.rs file. It currently holds all the code for the options which I found very overwhelming when trying to make some changes. Then while going through it I thought if there would be a more condensed way to express the options and came across clap. I also saw in some past issues that there was some interest to use it and thus decided I could give it a try.
The changes in other files (in discovery, playback,...) were to reshape some of the elements to be used with clap more harmoniously. For example: Changing the MIXERS from a const array into an enum so that the the variants are shown as "possible values". Some of these changes, in my opinion, are also beneficial on their own accord. Using the same example: With MIXERS being an enum, it no longer needs the code to iterate and find the mixer that was set in the options. Also there is no need for any of the mixers to have an extra separate impl just to associate a name. Also it helps using the types that are already enums like DeviceType by just deriving ValueEnum. On these we are also spared the hand made impl of FromStr.
Overall, I just think the clap derive way of doing options just looks cleaner and more accessible.

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.

2 participants