[WiP] moss: switch cli to use clap derive structs - #687
Draft
ermo wants to merge 21 commits into
Draft
Conversation
ermo
force-pushed
the
ermo/task/moss-refactor-cli-approach
branch
4 times, most recently
from
March 15, 2026 17:11
b8a732b to
1d81a7f
Compare
ermo
force-pushed
the
ermo/task/moss-refactor-cli-approach
branch
2 times, most recently
from
April 15, 2026 13:54
15db4d6 to
ff813c4
Compare
livingsilver94
force-pushed
the
ermo/task/moss-refactor-cli-approach
branch
10 times, most recently
from
August 6, 2026 13:33
8e08f50 to
ff776d2
Compare
Not done yet, just capturing current progress. Signed-off-by: Rune Morling <ermo@aerynos.com>
Signed-off-by: Rune Morling <ermo@aerynos.com>
Signed-off-by: Rune Morling <ermo@aerynos.com>
Signed-off-by: Rune Morling <ermo@aerynos.com>
Signed-off-by: Rune Morling <ermo@aerynos.com>
Rune said: "--upgrade-only is a misfeature. An index is supposed to be ABI-complete. Having packages installed from a previous index is thus ungood." And who am I to disagree!
cli::Error is currently 144 bytes large and clippy complains about that. To silence it, we heap allocate it. I consider this half a hack and we should ideally reduce Error's size, starting from client::Error.
livingsilver94
force-pushed
the
ermo/task/moss-refactor-cli-approach
branch
from
August 6, 2026 19:51
ff776d2 to
8978b24
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR migrates the CLI from function-based Clap declarations to clap_derive. clap_derive allows a declarative-like definition of the CLI command tree, so it's easier to maintain and extend.
Inside
moss/src/cliwe'll have a rootmod.rsfile and one module per each subcommand. Modules may be split into other submodules when the logic becomes complex and/or multiple tests are defined (e.g. for thepackagesubcommand).Each module will have a
Commandstruct withhandle()as its only public method. The signature of eachhandle()is not identical for allCommands, but depends on the logic it performs.Public structs/enum/functions will be at the top of each source file, private ones will be right below.
This PR fixes #196, but that issue plan functionalities that the moss backend does not yet support, and that's the reason why you'll see a bunch of
unimplemented!()calls across the PR.It also fixes #611.
Another thing I wanted to make consistent is the use verbs in their imperative conjugation instead of third-person, as these are commands. I also chose not to end phrases with a dot, like most programs out there.
I think the code could be cleaned a little (e.g. there are some Vec conversions I'm not sure they would be needed with more generic code), but that's out of the scope of this PR. I'm trying to introduce no functional and API changes here, except the parsing of CLI arguments: where possible, I'm leveraging Clap's automatic call of
TryFromto sanitize inputs, particularly for providers where I'm now passing theProviderstruct.TODO: print final CLI tree.