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

fix withdraw-withheld-tokens CLI subcommand showing wrong order of arguments in 'Usage' #312

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

nazreen
Copy link
Contributor

@nazreen nazreen commented Mar 23, 2025

Motivation

Closes #311

Changes

renamed arguments and amended descriptions.

From

<TOKEN_ACCOUNT_ADDRESS>    The address of the token account to receive withdrawn tokens

to

<FEE_RECIPIENT_ADDRESS>    The address of the token account to receive withdrawn tokens

and from

 <ACCOUNT_ADDRESS>...       The token accounts to withdraw from

to

<SOURCE_ADDRESS>...        The token account(s) to withdraw fees from.

The Usage output has been updated (corrected) from

USAGE:
    spl-token withdraw-withheld-tokens [OPTIONS] <ACCOUNT_ADDRESS|--include-mint> <TOKEN_ACCOUNT_ADDRESS> [--]

to

USAGE:
    spl-token withdraw-withheld-tokens [OPTIONS] <FEE_RECIPIENT_ADDRESS> <SOURCE_ADDRESS|--include-mint> [--]

Testing

Run

cargo run -- withdraw-withheld-tokens --help

Output will be like so:

USAGE:
    spl-token withdraw-withheld-tokens [OPTIONS] <FEE_RECIPIENT_ADDRESS> <SOURCE_ADDRESS|--include-mint> [--]

ARGS:
    <FEE_RECIPIENT_ADDRESS>    The token account to send withdrawn fees to.
    <SOURCE_ADDRESS>...        The token account(s) to withdraw fees from.

Which correctly

@nazreen nazreen changed the title fix withdraw-withheld-tokens CLI showing wrong order of arguments in 'Usage' fix withdraw-withheld-tokens CLI subcommand showing wrong order of arguments in 'Usage' Mar 23, 2025
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! The updated value names and help text is definitely good, but let's see what we can do with the arg group part

Comment on lines +2334 to +2338
.group(
ArgGroup::with_name("account_group")
.arg("account")
.required(true)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would create a bug unfortunately -- if you just want to withdraw withheld fees from the mint, the command would fail since accounts are required.

Rather than adding this new group, we can remove the following group (ArgGroup::with_name("source_or_mint")). That would cause no-ops if neither --include-mint nor any accounts are provided, but maybe that's better than the help text being incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh never mind, this actually works! I tested it out and it actually does everything properly.

Let's just go with this -- can you just add a comment explaining that we need this in order to show the help text correctly?

@nazreen
Copy link
Contributor Author

nazreen commented Mar 24, 2025 via email

Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@joncinque joncinque merged commit 3a9eff2 into solana-program:main Mar 24, 2025
19 of 20 checks passed
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.

withdraw-withheld-tokens CLI subcommand shows wrong order of arguments in --help output
2 participants