Skip to content

feat: add short option to task args#963

Open
rafikk wants to merge 1 commit intoaspect-build:mainfrom
rafikk:short-task-args
Open

feat: add short option to task args#963
rafikk wants to merge 1 commit intoaspect-build:mainfrom
rafikk:short-task-args

Conversation

@rafikk
Copy link

@rafikk rafikk commented Mar 13, 2026

This PR adds short options for all TaskArgs (except Positional and TrailingVarArgs).

Closes #925.

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: no
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

Task args can now include a short option in addition.

Test plan

  • Covered by existing test cases: yes
  • Manual testing; please provide instructions so we can reproduce: Manually tested by adding to one of the demo AXL tasks.

String {
required: bool,
default: String,
short: Option<String>,
Copy link
Author

Choose a reason for hiding this comment

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

Opening this PR as a draft because the current implementation doesn't validate that the short option is a single character.

I originally tried to add short with type Option<char> to both the starlark module and TarkArgs but ran into a few problems with unimplemented traits.

  • Starlark doesn't have a char type, so adding an argument of type char requires implementing UnpackValue and other traits. I wasn't sure if this is worth doing.
  • Using char in TaskArgs presented errors because Allocative is not implemented for char.

Let me know if you'd like to me to further pursue either of those changes.

I can also add a validation in each of the starlark module functions which returns an error if the length of the string != 1. That's probably the simplest way forward, but I wanted to see if there's a better way to do this in the type system.

Copy link
Member

Choose a reason for hiding this comment

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

String is the way to go, starlark does not have a char type and starlark-rust would have to cast to string anyway. lets make sure we validate length of the string.

@thesayyn thesayyn marked this pull request as ready for review March 13, 2026 18:01
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea01c549cf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


fn short_option(short: &Option<String>) -> Resettable<char> {
match short {
Some(text) => Resettable::Value(text.chars().nth(0).unwrap().into()),

Choose a reason for hiding this comment

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

P1 Badge Validate short option before taking first character

The new short-flag path can panic on user input: short is accepted as an arbitrary String in the task arg constructors, but this helper unconditionally does text.chars().nth(0).unwrap(). If a task defines short = "" for any named arg, command construction crashes instead of returning a configuration error, so the CLI exits before running the task. Please guard empty strings (and ideally enforce exactly one-character shorts) and surface a normal validation error.

Useful? React with 👍 / 👎.

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.

[FR]: Allow short flags for task args

2 participants